package com.hsnn.medstgmini.pro.base.service.Impl;

import java.sql.Timestamp;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.hsnn.medstgmini.pro.base.dao.AnaDruginfoDao;
import com.hsnn.medstgmini.pro.base.service.AnaDruginfoManager;
import com.hsnn.medstgmini.util.AreaUtil;
import com.hsnn.medstgmini.util.DateUtil;
import com.hsnn.medstgmini.util.Pagination;
import com.hsnn.medstgmini.util.ParseDate;
import com.hsnn.medstgmini.util.ParseNumber;

@Service
public class AnaDruginfoManagerImpl implements AnaDruginfoManager {
	@Autowired
	private AnaDruginfoDao anaDruginfoDao;

	@Override
	public Pagination getAnaByDrugs(Pagination page) {
		
		//获取药品采购日汇总信息
		Pagination anaTotal = anaDruginfoDao.getAnaByDrugs(page);
		//获取药品采购总量日汇总集合
		List<Map<String, Object>> list = anaDruginfoDao.getAnaChartByDrugs();
		String yDrug = "[";//图表y轴时间
		String total = "[";//采购金额
		String del = "[";//配送金额
		String ret = "[";//退货金额
		//循环解析数据
		for(int i =0;i<list.size();i++) {
			Map<String, Object> map = list.get(i);
			yDrug = yDrug +"'"+map.get("drug_name")+ "',";
			total = total + map.get("total_amount") + ",";
			del = del + map.get("del_amount") + ",";
			ret = ret + map.get("ret_amount") + ",";
		}
		
		if(!"[".equals(yDrug)) {//判断是否为空
			yDrug = yDrug.substring(0, yDrug.length()-1) + "]";
			total = total.substring(0, total.length()-1) + "]";
			del = del.substring(0, del.length()-1) + "]";
			ret = ret.substring(0, ret.length()-1) + "]";
			
			anaTotal.getConditions().put("yDrug", yDrug);
			anaTotal.getConditions().put("total", total);
			anaTotal.getConditions().put("del", del);
			anaTotal.getConditions().put("ret", ret);
		}
		
		return anaTotal;
	}

	@SuppressWarnings("unchecked")
	@Override
	public Pagination getAnaByHosp(Pagination page) {
		List<Map<String,Object>> list = (List<Map<String, Object>>) anaDruginfoDao.getAnaByHosp(page).getRows();
		for(Map<String,Object> data : list){
			Object base_ratio = data.get("base_ratio");
			Object ret_ratio = data.get("ret_ratio");
			Object date = data.get("date");
			data.put("date", date==null?"":date.toString().substring(0, 4)+"-"+date.toString().substring(4, 6)+"-"+date.toString().substring(6, 8));
			data.put("base_ratio", base_ratio==null?"":ParseNumber.toStrDecimal(Double.parseDouble(base_ratio.toString())*100,6)+"%");
			data.put("ret_ratio", ret_ratio==null?"":ParseNumber.toStrDecimal(Double.parseDouble(ret_ratio.toString())*100,6)+"%");
		}
		
		//获取药品采购总量月汇总集合
		List<Map<String, Object>> totalList = (List<Map<String, Object>>) anaDruginfoDao.getAnaTotalYesterday();
		String yTime = "[";//图表y轴时间
		String total = "[";//采购金额
		String del = "[";//配送金额
		String ret = "[";//退货金额
		String date = DateUtil.date(new Timestamp(System.currentTimeMillis()-1000 * 60 * 60 * 24)).replaceAll("-", "");
		//循环解析数据
		for(int i =0;i<totalList.size();i++) {
			Map<String, Object> map = totalList.get(i);
			String hospName =  map.get("hosp_name").toString();
			yTime = yTime +"'"+hospName+ "',";
			total = total + map.get("total_amount") + ",";
			del = del + map.get("del_amount") + ",";
			ret = ret + map.get("ret_amount") + ",";
		}
		
		if(!"[".equals(yTime)) {//判断是否为空
			yTime = yTime.substring(0, yTime.length()-1) + "]";
			total = total.substring(0, total.length()-1) + "]";
			del = del.substring(0, del.length()-1) + "]";
			ret = ret.substring(0, ret.length()-1) + "]";
			
			page.getConditions().put("yTime", yTime);
			page.getConditions().put("total", total);
			page.getConditions().put("del", del);
			page.getConditions().put("ret", ret);
		}		
		page.getConditions().put("chartTitle", date+"医院采购统计");	
		return page;
	}

	@SuppressWarnings("unchecked")
	@Override
	public Pagination getAnaByArea(Pagination page) {
		Pagination codePage = page;
		page = anaDruginfoDao.getAnaByArea(page);
		List<Map<String, Object>> list = (List<Map<String, Object>>) page.getRows();
		if (null != list && list.size() > 0){
			for (int i = 0; i < list.size(); i++){
				Map<String, Object> map = list.get(i);
				map.put("total_amount", map.get("total_amount")==null?"":ParseNumber.toStrDecimal(ParseNumber.toDouble(map.get("total_amount").toString()), 6));
				map.put("base_amount", map.get("base_amount")==null?"":ParseNumber.toStrDecimal(ParseNumber.toDouble(map.get("base_amount").toString()), 6));
				map.put("nonbase_amount", map.get("nonbase_amount")==null?"":ParseNumber.toStrDecimal(ParseNumber.toDouble(map.get("nonbase_amount").toString()), 6));
				map.put("del_amount", map.get("del_amount")==null?"":ParseNumber.toStrDecimal(ParseNumber.toDouble(map.get("del_amount").toString()), 6));
				map.put("ret_amount", map.get("ret_amount")==null?"":ParseNumber.toStrDecimal(ParseNumber.toDouble(map.get("ret_amount").toString()), 6));
				map.put("base_ratio", map.get("base_ratio")==null?"":ParseNumber.toStrDecimal(ParseNumber.toDouble(map.get("base_ratio").toString()) * 100, 6) + "%");
				map.put("del_ration", map.get("del_ration")==null?"":ParseNumber.toStrDecimal(ParseNumber.toDouble(map.get("del_ration").toString()) * 100, 6) + "%");
				map.put("ret_ratio", map.get("ret_ratio")==null?"":ParseNumber.toStrDecimal(ParseNumber.toDouble(map.get("ret_ratio").toString()) * 100, 6) + "%");
			}
		}
		
		//获取地区每日销售量前十的地区信息
		List<Map<String, Object>> chartList = anaDruginfoDao.getAnaChartByArea(codePage);
		String yArea = "[";//图表y轴地区名称
		String total = "[";//采购金额
		String base = "[";//基药金额
		String nobase = "[";//非基药金额
		String del = "[";//配送金额
		String ret = "[";//退货金额
		//循环解析数据
		for(int i =chartList.size()-1;i>=0;i--) {
			Map<String, Object> map = chartList.get(i);
			yArea = yArea +"'"+map.get("area_name")+ "',";
			total = total + map.get("total_amount") + ",";
			base = base + map.get("base_amount") + ",";
			nobase = nobase + map.get("nonbase_amount") + ",";
			del = del + map.get("del_amount") + ",";
			ret = ret + map.get("ret_amount") + ",";
		}
		
		if(!"[".equals(yArea)) {//判断是否为空
			yArea = yArea.substring(0, yArea.length()-1) + "]";
			total = total.substring(0, total.length()-1) + "]";
			base = base.substring(0, base.length()-1) + "]";
			nobase = nobase.substring(0, nobase.length()-1) + "]";
			del = del.substring(0, del.length()-1) + "]";
			ret = ret.substring(0, ret.length()-1) + "]";
			
			page.getConditions().put("yArea", yArea);
			page.getConditions().put("total", total);
			page.getConditions().put("base", base);
			page.getConditions().put("nobase", nobase);
			page.getConditions().put("del", del);
			page.getConditions().put("ret", ret);
		}
		return page;
	}
	
	@SuppressWarnings("unchecked")
	@Override
	public Pagination getAnaCompinfoByArea(Pagination page) {
		page = anaDruginfoDao.getAnaCompinfoByArea(page);
		List<Map<String, Object>> list = (List<Map<String, Object>>) page.getRows();
		if (null != list && list.size() > 0){
			for (int i = 0; i < list.size(); i++){
				Map<String, Object> map = list.get(i);
				map.put("total_amount", map.get("total_amount")==null?"":ParseNumber.toStrDecimal(ParseNumber.toDouble(map.get("total_amount").toString()), 6));
				map.put("base_amount", map.get("base_amount")==null?"":ParseNumber.toStrDecimal(ParseNumber.toDouble(map.get("base_amount").toString()), 6));
				map.put("nonbase_amount", map.get("nonbase_amount")==null?"":ParseNumber.toStrDecimal(ParseNumber.toDouble(map.get("nonbase_amount").toString()), 6));
				map.put("del_amount", map.get("del_amount")==null?"":ParseNumber.toStrDecimal(ParseNumber.toDouble(map.get("del_amount").toString()), 6));
				map.put("ret_amount", map.get("ret_amount")==null?"":ParseNumber.toStrDecimal(ParseNumber.toDouble(map.get("ret_amount").toString()), 6));
				map.put("base_ratio", map.get("base_ratio")==null?"":ParseNumber.toStrDecimal(ParseNumber.toDouble(map.get("base_ratio").toString()) * 100, 6) + "%");
				map.put("del_ratio", map.get("del_ration")==null?"":ParseNumber.toStrDecimal(ParseNumber.toDouble(map.get("del_ration").toString()) * 100, 6) + "%");
				map.put("ret_ratio", map.get("ret_ratio")==null?"":ParseNumber.toStrDecimal(ParseNumber.toDouble(map.get("ret_ratio").toString()) * 100, 6) + "%");
			}
		}
		return page;
	}
	/**
	 * 
	 *@category 获取药品采购统计,跳向按地区查询数据（年）
	 *@author 邱磊
	 *@date 2015年12月6日 上午10:06:50
	 *@param 
	 *@return Pagination
	 */
	@SuppressWarnings("unchecked")
	public Pagination getAnaByAreaWithYear(Pagination page){
		page =  anaDruginfoDao.getAnaByAreaWithYear(page);
		List<Map<String, Object>> list = (List<Map<String, Object>>) page.getRows();
		if (null != list && list.size() > 0){
			for (int i = 0; i < list.size(); i++){
				Map<String, Object> map = list.get(i);
				map.put("total_amount", map.get("total_amount")==null?"":ParseNumber.toStrDecimal(ParseNumber.toDouble(map.get("total_amount").toString()), 6));
				map.put("western_amount", map.get("western_amount")==null?"":ParseNumber.toStrDecimal(ParseNumber.toDouble(map.get("western_amount").toString()), 6));
				map.put("eastern_amount", map.get("eastern_amount")==null?"":ParseNumber.toStrDecimal(ParseNumber.toDouble(map.get("eastern_amount").toString()), 6));
				map.put("del_amount", map.get("del_amount")==null?"":ParseNumber.toStrDecimal(ParseNumber.toDouble(map.get("del_amount").toString()), 6));
				map.put("recp_amount", map.get("recp_amount")==null?"":ParseNumber.toStrDecimal(ParseNumber.toDouble(map.get("recp_amount").toString()), 6));
				map.put("eastern_ratio", map.get("eastern_ratio")==null?"":ParseNumber.toStrDecimal(ParseNumber.toDouble(map.get("eastern_ratio").toString()) * 100, 6) + "%");
				map.put("del_ratio", map.get("del_ratio")==null?"":ParseNumber.toStrDecimal(ParseNumber.toDouble(map.get("del_ratio").toString()) * 100, 6) + "%");
				map.put("recp_ratio", map.get("recp_ratio")==null?"":ParseNumber.toStrDecimal(ParseNumber.toDouble(map.get("recp_ratio").toString()) * 100, 6) + "%");
				map.put("ret_ratio", map.get("ret_ratio")==null?"":ParseNumber.toStrDecimal(ParseNumber.toDouble(map.get("ret_ratio").toString()) * 100, 6) + "%");
			}
		}
		
		List<Map<String, Object>> chartList = new ArrayList<Map<String,Object>>();
		if (StringUtils.isNotBlank(page.getConditions().get("areaId"))){
			//采购总量
			chartList = anaDruginfoDao.getAnaChartByWsjAllYear(page.getConditions().get("areaId"));
			String yTime = "[";//图表y轴时间
			String total = "[";//总采购金额
			String western = "[";//西药采购金额
			String eastern = "[";//中药采购金额
			//循环解析数据
			for(int i =0;i<list.size();i++) {
				Map<String, Object> map = chartList.get(i);
				yTime = yTime +"'"+map.get("date")+ "',";
				total = total + map.get("total_amount") + ",";
				western = western + map.get("western_amount") + ",";
				eastern = eastern + map.get("eastern_amount") + ",";
			}
			
			if(!"[".equals(yTime)) {//判断是否为空
				yTime = yTime.substring(0, yTime.length()-1) + "]";
				total = total.substring(0, total.length()-1) + "]";
				western = western.substring(0, western.length()-1) + "]";
				eastern = eastern.substring(0, eastern.length()-1) + "]";
				
				page.getConditions().put("yTime", yTime);
				page.getConditions().put("total", total);
				page.getConditions().put("western", western);
				page.getConditions().put("eastern", eastern);
			}
		}else {
			//获取地区销售量前十的上一年地区信息
			chartList = anaDruginfoDao.getAnaChartByAreaWithYear(page);
			String yArea = "[";//图表y轴时间
			String total = "[";//采购金额
			//循环解析数据
			for(int i =0;i<chartList.size();i++) {
				Map<String, Object> map = chartList.get(i);
				yArea = yArea +"'"+map.get("area_name")+ "',";
				total = total + map.get("total_amount") + ",";
			}
			
			if(!"[".equals(yArea)) {//判断是否为空
				yArea = yArea.substring(0, yArea.length()-1) + "]";
				total = total.substring(0, total.length()-1) + "]";
				
				page.getConditions().put("yArea", yArea);
				page.getConditions().put("total", total);
			}
		}
		
		return page;
	}
	
	@SuppressWarnings("unchecked")
	public Pagination getAnaCompinfoByAreaWithYear(Pagination page){
		page =  anaDruginfoDao.getAnaCompinfoByAreaWithYear(page);
		List<Map<String, Object>> list = (List<Map<String, Object>>) page.getRows();
		if (null != list && list.size() > 0){
			for (int i = 0; i < list.size(); i++){
				Map<String, Object> map = list.get(i);
				map.put("total_amount", map.get("total_amount")==null?"":ParseNumber.toStrDecimal(ParseNumber.toDouble(map.get("total_amount").toString()), 6));
				map.put("western_amount", map.get("western_amount")==null?"":ParseNumber.toStrDecimal(ParseNumber.toDouble(map.get("western_amount").toString()), 6));
				map.put("eastern_amount", map.get("eastern_amount")==null?"":ParseNumber.toStrDecimal(ParseNumber.toDouble(map.get("eastern_amount").toString()), 6));
				map.put("del_amount", map.get("del_amount")==null?"":ParseNumber.toStrDecimal(ParseNumber.toDouble(map.get("del_amount").toString()), 6));
				map.put("recp_amount", map.get("recp_amount")==null?"":ParseNumber.toStrDecimal(ParseNumber.toDouble(map.get("recp_amount").toString()), 6));
				map.put("eastern_ratio", map.get("eastern_ratio")==null?"":ParseNumber.toStrDecimal(ParseNumber.toDouble(map.get("eastern_ratio").toString()) * 100, 6) + "%");
				map.put("del_ratio", map.get("del_ratio")==null?"":ParseNumber.toStrDecimal(ParseNumber.toDouble(map.get("del_ratio").toString()) * 100, 6) + "%");
				map.put("recp_ratio", map.get("recp_ratio")==null?"":ParseNumber.toStrDecimal(ParseNumber.toDouble(map.get("recp_ratio").toString()) * 100, 6) + "%");
				map.put("ret_ratio", map.get("ret_ratio")==null?"":ParseNumber.toStrDecimal(ParseNumber.toDouble(map.get("ret_ratio").toString()) * 100, 6) + "%");
			}
		}
		return page;
	}

	/**
	 * 
	 *@category 获取药品采购统计,跳向按地区查询数据（季）
	 *@author 邱磊
	 *@date 2015年12月3日 上午10:06:50
	 *@param 
	 *@return Pagination
	 */
	@SuppressWarnings("unchecked")
	public Pagination getAnaByAreaWithSea(Pagination page){
		page =  anaDruginfoDao.getAnaByAreaWithSea(page);
		List<Map<String, Object>> list = (List<Map<String, Object>>) page.getRows();
		if (null != list && list.size() > 0){
			for (int i = 0; i < list.size(); i++){
				Map<String, Object> map = list.get(i);
				map.put("total_amount", map.get("total_amount")==null?"":ParseNumber.toStrDecimal(ParseNumber.toDouble(map.get("total_amount").toString()), 6));
				map.put("western_amount", map.get("western_amount")==null?"":ParseNumber.toStrDecimal(ParseNumber.toDouble(map.get("western_amount").toString()), 6));
				map.put("eastern_amount", map.get("eastern_amount")==null?"":ParseNumber.toStrDecimal(ParseNumber.toDouble(map.get("eastern_amount").toString()), 6));
				map.put("del_amount", map.get("del_amount")==null?"":ParseNumber.toStrDecimal(ParseNumber.toDouble(map.get("del_amount").toString()), 6));
				map.put("recp_amount", map.get("recp_amount")==null?"":ParseNumber.toStrDecimal(ParseNumber.toDouble(map.get("recp_amount").toString()), 6));
				map.put("eastern_ratio", map.get("eastern_ratio")==null?"":ParseNumber.toStrDecimal(ParseNumber.toDouble(map.get("eastern_ratio").toString()) * 100, 6) + "%");
				map.put("del_ratio", map.get("del_ratio")==null?"":ParseNumber.toStrDecimal(ParseNumber.toDouble(map.get("del_ratio").toString()) * 100, 6) + "%");
				map.put("recp_ratio", map.get("recp_ratio")==null?"":ParseNumber.toStrDecimal(ParseNumber.toDouble(map.get("recp_ratio").toString()) * 100, 6) + "%");
				map.put("ret_ratio", map.get("ret_ratio")==null?"":ParseNumber.toStrDecimal(ParseNumber.toDouble(map.get("ret_ratio").toString()) * 100, 6) + "%");
			}
		}
		
		List<Map<String, Object>> chartList = new ArrayList<Map<String,Object>>();
		if (StringUtils.isNotBlank(page.getConditions().get("areaId"))){
			//采购总量
			chartList = anaDruginfoDao.getAnaChartByWsjAllSea(page.getConditions().get("areaId"));
			String yTime = "[";//图表y轴时间
			String total = "[";//总采购金额
			String western = "[";//西药采购金额
			String eastern = "[";//中药采购金额
			//循环解析数据
			for(int i =0;i<list.size();i++) {
				Map<String, Object> map = chartList.get(i);
				yTime = yTime +"'"+map.get("date")+ "',";
				total = total + map.get("total_amount") + ",";
				western = western + map.get("western_amount") + ",";
				eastern = eastern + map.get("eastern_amount") + ",";
			}
			
			if(!"[".equals(yTime)) {//判断是否为空
				yTime = yTime.substring(0, yTime.length()-1) + "]";
				total = total.substring(0, total.length()-1) + "]";
				western = western.substring(0, western.length()-1) + "]";
				eastern = eastern.substring(0, eastern.length()-1) + "]";
				
				page.getConditions().put("yTime", yTime);
				page.getConditions().put("total", total);
				page.getConditions().put("western", western);
				page.getConditions().put("eastern", eastern);
			}
		}else {
			//获取地区销售量前十的上一季度地区信息
			chartList = anaDruginfoDao.getAnaChartByAreaWithSea(page);
			String yArea = "[";//图表y轴时间
			String total = "[";//采购金额
			//循环解析数据
			for(int i =0;i<chartList.size();i++) {
				Map<String, Object> map = chartList.get(i);
				yArea = yArea +"'"+map.get("area_name")+ "',";
				total = total + map.get("total_amount") + ",";
			}
			
			if(!"[".equals(yArea)) {//判断是否为空
				yArea = yArea.substring(0, yArea.length()-1) + "]";
				total = total.substring(0, total.length()-1) + "]";
				
				page.getConditions().put("yArea", yArea);
				page.getConditions().put("total", total);
			}
		}
		
		return page;
	}
	
	@SuppressWarnings("unchecked")
	public Pagination getAnaCompinfoByAreaWithSea(Pagination page){
		page =  anaDruginfoDao.getAnaCompinfoByAreaWithSea(page);
		List<Map<String, Object>> list = (List<Map<String, Object>>) page.getRows();
		if (null != list && list.size() > 0){
			for (int i = 0; i < list.size(); i++){
				Map<String, Object> map = list.get(i);
				map.put("total_amount", map.get("total_amount")==null?"":ParseNumber.toStrDecimal(ParseNumber.toDouble(map.get("total_amount").toString()), 6));
				map.put("western_amount", map.get("western_amount")==null?"":ParseNumber.toStrDecimal(ParseNumber.toDouble(map.get("western_amount").toString()), 6));
				map.put("eastern_amount", map.get("eastern_amount")==null?"":ParseNumber.toStrDecimal(ParseNumber.toDouble(map.get("eastern_amount").toString()), 6));
				map.put("del_amount", map.get("del_amount")==null?"":ParseNumber.toStrDecimal(ParseNumber.toDouble(map.get("del_amount").toString()), 6));
				map.put("recp_amount", map.get("recp_amount")==null?"":ParseNumber.toStrDecimal(ParseNumber.toDouble(map.get("recp_amount").toString()), 6));
				map.put("eastern_ratio", map.get("eastern_ratio")==null?"":ParseNumber.toStrDecimal(ParseNumber.toDouble(map.get("eastern_ratio").toString()) * 100, 6) + "%");
				map.put("del_ratio", map.get("del_ratio")==null?"":ParseNumber.toStrDecimal(ParseNumber.toDouble(map.get("del_ratio").toString()) * 100, 6) + "%");
				map.put("recp_ratio", map.get("recp_ratio")==null?"":ParseNumber.toStrDecimal(ParseNumber.toDouble(map.get("recp_ratio").toString()) * 100, 6) + "%");
				map.put("ret_ratio", map.get("ret_ratio")==null?"":ParseNumber.toStrDecimal(ParseNumber.toDouble(map.get("ret_ratio").toString()) * 100, 6) + "%");
			}
		}
		return page;
	}
	/**
	 * @category 按医院统计(年)
	 * @date 2015年12月1日10:55:55
	 * @return
	 */
	@SuppressWarnings("unchecked")
	@Override
	public Pagination getYearAnaByHosp(Pagination page) {
		List<Map<String,Object>> list = (List<Map<String, Object>>) anaDruginfoDao.getYearAnaByHosp(page).getRows();
		formatAna(list);
		
		//获取药品采购总量月汇总集合
		List<Map<String, Object>> totalList = (List<Map<String, Object>>) anaDruginfoDao.getAnaTotalLastYear(page);
		String yTime = "[";//图表y轴时间
		String total = "[";//采购金额
		//循环解析数据
		for(int i =totalList.size()-1;i>0;i--) {
			Map<String, Object> map = totalList.get(i);
			String hospName =  map.get("hosp_name").toString();
			yTime = yTime +"'"+hospName+ "',";
			String totalAmount = map.get("total_amount")==null?"":ParseNumber.toStrDecimal(ParseNumber.toDouble(map.get("total_amount").toString())/10000, 6);
			total = total +totalAmount + ",";
		}
		
		if(!"[".equals(yTime)) {//判断是否为空
			yTime = yTime.substring(0, yTime.length()-1) + "]";
			total = total.substring(0, total.length()-1) + "]";
			page.getConditions().put("yTime", yTime);
			page.getConditions().put("total", total);
		}
		return page;
				
	}
	
	@SuppressWarnings("unchecked")
	public Pagination getAnaByAreaWithMon(Pagination page){
		
		page =  anaDruginfoDao.getAnaByAreaWithMon(page);
		List<Map<String, Object>> list = (List<Map<String, Object>>) page.getRows();
		if (null != list && list.size() > 0){
			for (int i = 0; i < list.size(); i++){
				Map<String, Object> map = list.get(i);
				map.put("total_amount", map.get("total_amount")==null?"":ParseNumber.toStrDecimal(ParseNumber.toDouble(map.get("total_amount").toString()), 6));
				map.put("western_amount", map.get("western_amount")==null?"":ParseNumber.toStrDecimal(ParseNumber.toDouble(map.get("western_amount").toString()), 6));
				map.put("eastern_amount", map.get("eastern_amount")==null?"":ParseNumber.toStrDecimal(ParseNumber.toDouble(map.get("eastern_amount").toString()), 6));
				map.put("del_amount", map.get("del_amount")==null?"":ParseNumber.toStrDecimal(ParseNumber.toDouble(map.get("del_amount").toString()), 6));
				map.put("recp_amount", map.get("recp_amount")==null?"":ParseNumber.toStrDecimal(ParseNumber.toDouble(map.get("recp_amount").toString()), 6));
				map.put("eastern_ratio", map.get("eastern_ratio")==null?"":ParseNumber.toStrDecimal(ParseNumber.toDouble(map.get("eastern_ratio").toString()) * 100, 6) + "%");
				map.put("del_ratio", map.get("del_ratio")==null?"":ParseNumber.toStrDecimal(ParseNumber.toDouble(map.get("del_ratio").toString()) * 100, 6) + "%");
				map.put("recp_ratio", map.get("recp_ratio")==null?"":ParseNumber.toStrDecimal(ParseNumber.toDouble(map.get("recp_ratio").toString()) * 100, 6) + "%");
				map.put("ret_ratio", map.get("ret_ratio")==null?"":ParseNumber.toStrDecimal(ParseNumber.toDouble(map.get("ret_ratio").toString()) * 100, 6) + "%");
				
				if (StringUtils.isNotBlank(page.getConditions().get("startMon")) && !StringUtils.isNotBlank(page.getConditions().get("endMon"))){
//					map.put("date", page.getConditions().get("startMon")+"-"+ParseDate.parseDateToYm(ParseDate.addMonth(new Date(), -1)));
					map.put("date", page.getConditions().get("startMon")+"-"+ParseDate.parseDateToYm(new Date()));
				}else if (StringUtils.isNotBlank(page.getConditions().get("startMon")) && StringUtils.isNotBlank(page.getConditions().get("endMon"))){
					map.put("date", page.getConditions().get("startMon")+"-"+page.getConditions().get("endMon"));
				}
			}
		}
		
		List<Map<String, Object>> chartList = new ArrayList<Map<String,Object>>();
		if (StringUtils.isNotBlank(page.getConditions().get("areaId"))){
			//采购总量
			chartList = anaDruginfoDao.getAnaChartByWsjAllMonth(page);
			String yTime = "[";//图表y轴时间
			String total = "[";//总采购金额
			String western = "[";//西药采购金额
			String eastern = "[";//中药采购金额
			//循环解析数据
			for(int i =0;i<chartList.size();i++) {
				Map<String, Object> map = chartList.get(i);
				yTime = yTime +"'"+map.get("date")+ "',";
				total = total + map.get("total_amount") + ",";
				western = western + map.get("del_amount") + ",";
				eastern = eastern + map.get("recp_amount") + ",";
			}
			
			if(!"[".equals(yTime)) {//判断是否为空
				yTime = yTime.substring(0, yTime.length()-1) + "]";
				total = total.substring(0, total.length()-1) + "]";
				western = western.substring(0, western.length()-1) + "]";
				eastern = eastern.substring(0, eastern.length()-1) + "]";
				
				page.getConditions().put("yTime", yTime);
				page.getConditions().put("total", total);
				page.getConditions().put("western", western);
				page.getConditions().put("eastern", eastern);
			}
		}
		
		return page;
	}
	@SuppressWarnings("unchecked")
	public Pagination getAnaCompinfoByAreaWithMon(Pagination page){
		page =  anaDruginfoDao.getAnaCompinfoByAreaWithMon(page);
		List<Map<String, Object>> list = (List<Map<String, Object>>) page.getRows();
		if (null != list && list.size() > 0){
			for (int i = 0; i < list.size(); i++){
				Map<String, Object> map = list.get(i);
				map.put("total_amount", map.get("total_amount")==null?"":ParseNumber.toStrDecimal(ParseNumber.toDouble(map.get("total_amount").toString()), 6));
				map.put("western_amount", map.get("western_amount")==null?"":ParseNumber.toStrDecimal(ParseNumber.toDouble(map.get("western_amount").toString()), 6));
				map.put("eastern_amount", map.get("eastern_amount")==null?"":ParseNumber.toStrDecimal(ParseNumber.toDouble(map.get("eastern_amount").toString()), 6));
				map.put("del_amount", map.get("del_amount")==null?"":ParseNumber.toStrDecimal(ParseNumber.toDouble(map.get("del_amount").toString()), 6));
				map.put("recp_amount", map.get("recp_amount")==null?"":ParseNumber.toStrDecimal(ParseNumber.toDouble(map.get("recp_amount").toString()), 6));
				map.put("eastern_ratio", map.get("eastern_ratio")==null?"":ParseNumber.toStrDecimal(ParseNumber.toDouble(map.get("eastern_ratio").toString()) * 100, 6) + "%");
				map.put("del_ratio", map.get("del_ratio")==null?"":ParseNumber.toStrDecimal(ParseNumber.toDouble(map.get("del_ratio").toString()) * 100, 6) + "%");
				map.put("recp_ratio", map.get("recp_ratio")==null?"":ParseNumber.toStrDecimal(ParseNumber.toDouble(map.get("recp_ratio").toString()) * 100, 6) + "%");
				map.put("ret_ratio", map.get("ret_ratio")==null?"":ParseNumber.toStrDecimal(ParseNumber.toDouble(map.get("ret_ratio").toString()) * 100, 6) + "%");
			}
		}
		return page;
	}
	/**
	 * @category 按医院统计(季度)
	 * @date 2015年12月1日10:55:55
	 * @return
	 */
	@SuppressWarnings("unchecked")
	@Override
	public Pagination getSeaAnaByHosp(Pagination page) {
		List<Map<String,Object>> list = (List<Map<String, Object>>) anaDruginfoDao.getSeaAnaByHosp(page).getRows();
		formatAna(list);
		//获取药品采购总量月汇总集合
		List<Map<String, Object>> totalList = (List<Map<String, Object>>) anaDruginfoDao.getAnaTotalLastQuarter(page);
		String yTime = "[";//图表y轴时间
		String total = "[";//采购金额
		//循环解析数据
		for(int i =totalList.size()-1;i>0;i--) {
			Map<String, Object> map = totalList.get(i);
			String hospName =  map.get("hosp_name").toString();
			yTime = yTime +"'"+hospName+ "',";
			String totalAmount = map.get("total_amount")==null?"":ParseNumber.toStrDecimal(ParseNumber.toDouble(map.get("total_amount").toString())/10000, 6);
			total = total +totalAmount + ",";
		}
		
		if(!"[".equals(yTime)) {//判断是否为空
			yTime = yTime.substring(0, yTime.length()-1) + "]";
			total = total.substring(0, total.length()-1) + "]";
			
			page.getConditions().put("yTime", yTime);
			page.getConditions().put("total", total);
		}	
		return page;
	}

	/**
	 * @category 按医院统计(月)
	 * @date 2015年12月1日10:55:55
	 * @return
	 */
	@SuppressWarnings("unchecked")
	public Pagination getMonthAnaByHosp(Pagination page){
		
		page =  anaDruginfoDao.getMonthAnaByHosp(page);
		List<Map<String, Object>> list = (List<Map<String, Object>>) page.getRows();
		if (null != list && list.size() > 0){
			for (int i = 0; i < list.size(); i++){
				Map<String, Object> map = list.get(i);
				String hospClassify = String.valueOf(map.get("hosp_classify"));
				map.put("hosp_classify", hospClassify.equals("2")?"基层医疗机构":(hospClassify.equals("1")?"县级及县以上医疗机构":""));
				map.put("total_amount", map.get("total_amount")==null?"":ParseNumber.toStrDecimal(ParseNumber.toDouble(map.get("total_amount").toString()), 6));
				map.put("western_amount", map.get("western_amount")==null?"":ParseNumber.toStrDecimal(ParseNumber.toDouble(map.get("western_amount").toString()), 6));
				map.put("eastern_amount", map.get("eastern_amount")==null?"":ParseNumber.toStrDecimal(ParseNumber.toDouble(map.get("eastern_amount").toString()), 6));
				map.put("eastern_ratio", map.get("eastern_ratio")==null?"":ParseNumber.toStrDecimal(ParseNumber.toDouble(map.get("eastern_ratio").toString()) * 100, 6) + "%");
				map.put("del_amount", map.get("del_amount")==null?"":ParseNumber.toStrDecimal(ParseNumber.toDouble(map.get("del_amount").toString()), 6));
				map.put("del_ratio", map.get("del_ratio")==null?"":ParseNumber.toStrDecimal(ParseNumber.toDouble(map.get("del_ratio").toString()) * 100, 6) + "%");
				map.put("recp_amount", map.get("recp_amount")==null?"":ParseNumber.toStrDecimal(ParseNumber.toDouble(map.get("recp_amount").toString()), 6));
				map.put("recp_ratio", map.get("recp_ratio")==null?"":ParseNumber.toStrDecimal(ParseNumber.toDouble(map.get("recp_ratio").toString()) * 100, 6) + "%");
				if (StringUtils.isNotBlank(page.getConditions().get("startMon")) && !StringUtils.isNotBlank(page.getConditions().get("endMon"))){
//					map.put("date", page.getConditions().get("startMon")+"-"+ParseDate.parseDateToYm(ParseDate.addMonth(new Date(), -1)));
					map.put("date", page.getConditions().get("startMon")+"-"+ParseDate.parseDateToYm(new Date()));
				}else if (StringUtils.isNotBlank(page.getConditions().get("startMon")) && StringUtils.isNotBlank(page.getConditions().get("endMon"))){
					map.put("date", page.getConditions().get("startMon")+"-"+page.getConditions().get("endMon"));
				}
			}
		}
		return page;
	}
	
	
	/**
	 * @category 按药品汇总（月）
	 * @date 2015-12-04
	 * @author lil
	 * @param page
	 * @return Pagination
	 */
	@SuppressWarnings("unchecked")
	@Override
	public Pagination getAnaByDrugsMonth(Pagination page) {
		if (StringUtils.isNotBlank(page.getConditions().get("starttime")) || StringUtils.isNotBlank(page.getConditions().get("areaId"))){
			String date = "";
			if(StringUtils.isNotBlank(page.getConditions().get("starttime"))){
				 page.getConditions().put("endtime",StringUtils.isNotBlank(page.getConditions().get("endtime"))?page.getConditions().get("endtime"):ParseDate.parseDateToYm(ParseDate.addMonth(new Date(), 0)) ) ;
				 date = "\""+page.getConditions().get("starttime")+"-"+page.getConditions().get("endtime")+"\"";
			}else{date = "a.date" ;}
			page.getConditions().put("date", date);
			page = anaDruginfoDao.getAnaByDrugsMonthPool(page);
		}else{
			page = anaDruginfoDao.getAnaByDrugsMonth(page);
		}
		formatAna((List<Map<String,Object>>)page.getRows());
		return page;
	}
	
	/**
	 * @category 按药品汇总（季度）
	 * @date 2015-12-04
	 * @author lil
	 * @param page
	 * @return Pagination
	 */
	@SuppressWarnings("unchecked")
	@Override
	public Pagination getAnaByDrugsSea(Pagination page) {
		
		//获取药品采购季度汇总信息
		Pagination anaTotal = anaDruginfoDao.getAnaByDrugsSea(page);
		formatAna((List<Map<String,Object>>)anaTotal.getRows());
		//获取药品采购总量季度汇总集合
		List<Map<String, Object>> list = anaDruginfoDao.getAnaChartByDrugsSea(page);
		String yDrug = "[";//图表y轴时间
		String total = "[";//采购金额
		//循环解析数据
		for(int i =list.size()-1;i>=0;i--) {
			Map<String, Object> map = list.get(i);
			yDrug = yDrug +"'"+map.get("drug_name")+ "',";
			String totalAmount = map.get("total_amount")==null?"":ParseNumber.toStrDecimal(ParseNumber.toDouble(map.get("total_amount").toString())/10000, 6);
			total = total +totalAmount + ",";
		}
		
		if(!"[".equals(yDrug)) {//判断是否为空
			yDrug = yDrug.substring(0, yDrug.length()-1) + "]";
			total = total.substring(0, total.length()-1) + "]";
			
			anaTotal.getConditions().put("yDrug", yDrug);
			anaTotal.getConditions().put("total", total);
		}
		
		return anaTotal;
	}
	
	/**
	 * @category 按药品汇总（年度）
	 * @date 2015-12-04
	 * @author lil
	 * @param page
	 * @return Pagination
	 */
	@SuppressWarnings("unchecked")
	@Override
	public Pagination getAnaByDrugsYear(Pagination page) {
		
		//获取药品采购年汇总信息
		Pagination anaTotal = anaDruginfoDao.getAnaByDrugsYear(page);
		formatAna((List<Map<String,Object>>)anaTotal.getRows());
		//获取药品采购总量年汇总集合
		List<Map<String, Object>> list = anaDruginfoDao.getAnaChartByDrugsYear(page);
		String yDrug = "[";//图表y轴时间
		String total = "[";//采购金额
		//循环解析数据
		for(int i =list.size()-1;i>=0;i--) {
			Map<String, Object> map = list.get(i);
			yDrug = yDrug +"'"+map.get("drug_name")+ "',";
			String totalAmount = map.get("total_amount")==null?"":ParseNumber.toStrDecimal(ParseNumber.toDouble(map.get("total_amount").toString())/10000, 6);
			total = total +totalAmount + ",";
		}
		
		if(!"[".equals(yDrug)) {//判断是否为空
			yDrug = yDrug.substring(0, yDrug.length()-1) + "]";
			total = total.substring(0, total.length()-1) + "]";
			anaTotal.getConditions().put("yDrug", yDrug);
			anaTotal.getConditions().put("total", total);
		}
		
		return anaTotal;
	}
	
	/**
	 * @category 获取药品采购总量日汇总数据
	 * @date 2015年12月06日
	 * @author lil
	 * @param page
	 * @return
	 */
	@SuppressWarnings("unchecked")
	@Override
	public Pagination getAnaListByTime(Pagination page) {
		
		//获取药品采购总量日汇总数据
		Pagination anaTotal = anaDruginfoDao.getAnaListByTime(page);
		List<Map<String, Object>> listPage = (List<Map<String, Object>>) page.getRows();
		if (null != listPage && listPage.size() > 0){
			for (int i = 0; i < listPage.size(); i++){
				Map<String, Object> map = listPage.get(i);
				map.put("total_amount", map.get("total_amount")==null?"":ParseNumber.toStrDecimal(ParseNumber.toDouble(map.get("total_amount").toString()), 6));
				map.put("del_amount", map.get("del_amount")==null?"":ParseNumber.toStrDecimal(ParseNumber.toDouble(map.get("del_amount").toString()), 6));
				map.put("ret_amount", map.get("ret_amount")==null?"":ParseNumber.toStrDecimal(ParseNumber.toDouble(map.get("ret_amount").toString()), 6));
				map.put("del_ratio", map.get("del_ratio")==null?"":ParseNumber.toStrDecimal(ParseNumber.toDouble(map.get("del_ratio").toString()) * 100, 6) + "%");
				map.put("ret_ratio", map.get("ret_ratio")==null?"":ParseNumber.toStrDecimal(ParseNumber.toDouble(map.get("ret_ratio").toString()) * 100, 6) + "%");
			}
		}
		
		
		//获取药品采购总量日汇总集合
		List<Map<String, Object>> list = anaDruginfoDao.getAnaTotalByTime();
		String yTime = "[";//图表y轴时间
		String total = "[";//采购金额
		String del = "[";//配送金额
		String ret = "[";//退货金额
		//循环解析数据
		for(int i =0;i<list.size();i++) {
			
			Map<String, Object> map = list.get(i);
			String isBasic =  Integer.parseInt(map.get("is_basic")+"") == 1?"基药":"非基药";
			String date = map.get("date")+"";
			yTime = yTime +"'"+date+isBasic+ "',";
			total = total + map.get("total_amount") + ",";
			del = del + map.get("del_amount") + ",";
			ret = ret + map.get("ret_amount") + ",";
		}
		
		if(!"[".equals(yTime)) {//判断是否为空
			yTime = yTime.substring(0, yTime.length()-1) + "]";
			total = total.substring(0, total.length()-1) + "]";
			del = del.substring(0, del.length()-1) + "]";
			ret = ret.substring(0, ret.length()-1) + "]";
			
			anaTotal.getConditions().put("yTime", yTime);
			anaTotal.getConditions().put("total", total);
			anaTotal.getConditions().put("del", del);
			anaTotal.getConditions().put("ret", ret);
		}
		
		return anaTotal;
	}
	
	/**
	 * @category 采购总体情况汇总信息（月度）
	 * @date 2015年12月22日
	 * @author lil
	 * @param page
	 * @return
	 */
	@SuppressWarnings("unchecked")
	@Override
	public Pagination getAnaByAllMonth(Pagination page) {
		
		//采购总量汇总
		Pagination anaTotal = anaDruginfoDao.getAnaByAllMonth(page);
		List<Map<String, Object>> listPage = (List<Map<String, Object>>) page.getRows();
		if (null != listPage && listPage.size() > 0){
			for (int i = 0; i < listPage.size(); i++){
				Map<String, Object> map = listPage.get(i);
				map.put("total_amount", map.get("total_amount")==null?"":ParseNumber.toStrDecimal(ParseNumber.toDouble(map.get("total_amount").toString()), 6));
				map.put("del_amount", map.get("del_amount")==null?"":ParseNumber.toStrDecimal(ParseNumber.toDouble(map.get("del_amount").toString()), 6));
				map.put("ret_amount", map.get("ret_amount")==null?"":ParseNumber.toStrDecimal(ParseNumber.toDouble(map.get("ret_amount").toString()), 6));
				map.put("recp_amount", map.get("recp_amount")==null?"":ParseNumber.toStrDecimal(ParseNumber.toDouble(map.get("recp_amount").toString()), 6));
				map.put("del_ratio", map.get("del_ratio")==null?"":ParseNumber.toStrDecimal(ParseNumber.toDouble(map.get("del_ratio").toString()) * 100, 6) + "%");
				map.put("ret_ratio", map.get("ret_ratio")==null?"":ParseNumber.toStrDecimal(ParseNumber.toDouble(map.get("ret_ratio").toString()) * 100, 6) + "%");
				map.put("recp_ratio", map.get("recp_ratio")==null?"":ParseNumber.toStrDecimal(ParseNumber.toDouble(map.get("recp_ratio").toString()) * 100, 6) + "%");
				
				if (StringUtils.isNotBlank(page.getConditions().get("starttime")) && !StringUtils.isNotBlank(page.getConditions().get("endtime"))){
//					map.put("date", page.getConditions().get("starttime")+"-"+ParseDate.parseDateToYm(ParseDate.addMonth(new Date(), -1)));
					map.put("date", page.getConditions().get("starttime")+"-"+ParseDate.parseDateToYm(new Date()));
				}else if (StringUtils.isNotBlank(page.getConditions().get("starttime")) && StringUtils.isNotBlank(page.getConditions().get("endtime"))){
					map.put("date", page.getConditions().get("starttime")+"-"+page.getConditions().get("endtime"));
				}
			}
		}
		
		if(!StringUtils.isNotBlank(page.getConditions().get("NoPage"))){
			//采购总量
			List<Map<String, Object>> list = anaDruginfoDao.getAnaChartByAllMonth(page);
			String yTime = "[";//图表y轴时间
			String total = "[";//采购金额
			String del = "[";//配送金额
			String recp = "[";//入库金额
			//循环解析数据
			for(int i =0;i<list.size();i++) {
				Map<String, Object> map = list.get(i);
				String yTimeStr = String.valueOf(map.get("date"));
				yTimeStr = yTimeStr.toString().substring(0, 4)+"年"+yTimeStr.toString().substring(4, 6)+"月";
				
				
				yTime = yTime +"'"+yTimeStr+ "',";
				total = total +"'"+map.get("total_amount")+ "',";
				del = del +"'"+map.get("del_amount")+ "',";
				recp = recp +"'"+map.get("recp_amount")+ "',";
			}
			
			if(!"[".equals(yTime)) {//判断是否为空
				yTime = yTime.substring(0, yTime.length()-1) + "]";
				total = total.substring(0, total.length()-1) + "]";
				del = del.substring(0, del.length()-1) + "]";
				recp = recp.substring(0, recp.length()-1) + "]";
				
				anaTotal.getConditions().put("yTime", yTime);
				anaTotal.getConditions().put("total", total);
				anaTotal.getConditions().put("del", del);
				anaTotal.getConditions().put("recp", recp);
			}
		}
		/*Map<String, Object> dateMap = new HashMap<String, Object>();
		//循环解析数据
		for(int i =0;i<list.size();i++) {
			Map<String, Object> map = list.get(i);
			int drugCat = Integer.parseInt(map.get("drug_cat")+"");
			if(dateMap.size() == 0) {
				dateMap.put("date", map.get("date"));
				if(drugCat == 1) {
					dateMap.put("total_amount", map.get("total_amount"));
					dateMap.put("pro_count", map.get("pro_count"));
					dateMap.put("total2", 0);
					dateMap.put("pro2", 0);
				}else {
					dateMap.put("total_amount", 0);
					dateMap.put("pro_count", 0);
					dateMap.put("total2", map.get("total_amount"));
					dateMap.put("pro2", map.get("pro_count"));
				}
				
			}else if(dateMap.get("date").equals(map.get("date"))){
				if(drugCat == 1) {
					dateMap.put("total_amount", Double.parseDouble(map.get("total_amount")+"")+Double.parseDouble(dateMap.get("total_amount")+""));
					dateMap.put("pro_count", Double.parseDouble(map.get("pro_count")+"")+Double.parseDouble(dateMap.get("pro_count")+""));
				}else {
					dateMap.put("total2", Double.parseDouble(map.get("total_amount")+"")+Double.parseDouble(dateMap.get("total2")+""));
					dateMap.put("pro2", Double.parseDouble(map.get("pro_count")+"")+Double.parseDouble(dateMap.get("pro2")+""));
				}
				
				if(i == list.size()-1) {
					String yTimeStr = String.valueOf(dateMap.get("date"));
					if(!"".equals(yTimeStr) && !"null".equals(yTimeStr)) {
						yTimeStr = yTimeStr.toString().substring(0, 4)+"年"+yTimeStr.toString().substring(4, 6)+"月";
					}
					
					yTime = yTime +"'"+yTimeStr+ "',";
					String total_amountStr = dateMap.get("total_amount")+"";
					if("null".equals(total_amountStr)) {
						total_amountStr = "";
					}
					totalBasic = totalBasic + total_amountStr + ",";
					String pro_countStr = dateMap.get("pro_count")+"";
					if("null".equals(pro_countStr)) {
						pro_countStr = "";
					}
					proBasic = proBasic + pro_countStr+ ",";
					String total2Str = dateMap.get("total2")+"";
					if("null".equals(total2Str)) {
						total2Str = "";
					}
					total = total + total2Str + ",";
					String pro2Str = dateMap.get("pro2")+"";
					if("null".equals(pro2Str)) {
						pro2Str = "";
					}
					pro = pro + pro2Str+ ",";
					dateMap.clear();
				}
			}else {
				String yTimeStr = String.valueOf(dateMap.get("date"));
				if(!"".equals(yTimeStr) && !"null".equals(yTimeStr)) {
					yTimeStr = yTimeStr.toString().substring(0, 4)+"年"+yTimeStr.toString().substring(4, 6)+"月";
				}
				
				yTime = yTime +"'"+yTimeStr+ "',";
				String total_amountStr = dateMap.get("total_amount")+"";
				if("null".equals(total_amountStr)) {
					total_amountStr = "";
				}
				totalBasic = totalBasic + total_amountStr + ",";
				String pro_countStr = dateMap.get("pro_count")+"";
				if("null".equals(pro_countStr)) {
					pro_countStr = "";
				}
				proBasic = proBasic + pro_countStr+ ",";
				String total2Str = dateMap.get("total2")+"";
				if("null".equals(total2Str)) {
					total2Str = "";
				}
				total = total + total2Str + ",";
				String pro2Str = dateMap.get("pro2")+"";
				if("null".equals(pro2Str)) {
					pro2Str = "";
				}
				pro = pro + pro2Str+ ",";
				dateMap.clear();
				
				dateMap.put("date", map.get("date"));
				if(drugCat == 1) {
					dateMap.put("total_amount", map.get("total_amount"));
					dateMap.put("pro_count", map.get("pro_count"));
					dateMap.put("total2", 0);
					dateMap.put("pro2", 0);
				}else {
					dateMap.put("total_amount", 0);
					dateMap.put("pro_count", 0);
					dateMap.put("total2", map.get("total_amount"));
					dateMap.put("pro2", map.get("pro_count"));
				}
			}
		}
		
		if(!"[".equals(yTime)) {//判断是否为空
			yTime = yTime.substring(0, yTime.length()-1) + "]";
			totalBasic = totalBasic.substring(0, totalBasic.length()-1) + "]";
			proBasic = proBasic.substring(0, proBasic.length()-1) + "]";
			total = total.substring(0, total.length()-1) + "]";
			pro = pro.substring(0, pro.length()-1) + "]";
			
			anaTotal.getConditions().put("yTime", yTime);
			anaTotal.getConditions().put("totalBasic", totalBasic);
			anaTotal.getConditions().put("proBasic", proBasic);
			anaTotal.getConditions().put("total", total);
			anaTotal.getConditions().put("pro", pro);
		}*/
		
		return anaTotal;
	}
	
	/**
	 * @category 采购总体情况汇总信息（季度）
	 * @date 2015年12月22日
	 * @author lil
	 * @param page
	 * @return
	 */
	@SuppressWarnings("unchecked")
	@Override
	public Pagination getAnaByAllSea(Pagination page) {
		
		//季度查询
		Pagination anaTotal = anaDruginfoDao.getAnaByAllSea(page);
		List<Map<String, Object>> listPage = (List<Map<String, Object>>) page.getRows();
		if (null != listPage && listPage.size() > 0){
			for (int i = 0; i < listPage.size(); i++){
				Map<String, Object> map = listPage.get(i);
				map.put("total_amount", map.get("total_amount")==null?"":ParseNumber.toStrDecimal(ParseNumber.toDouble(map.get("total_amount").toString()), 6));
				map.put("del_amount", map.get("del_amount")==null?"":ParseNumber.toStrDecimal(ParseNumber.toDouble(map.get("del_amount").toString()), 6));
				map.put("ret_amount", map.get("ret_amount")==null?"":ParseNumber.toStrDecimal(ParseNumber.toDouble(map.get("ret_amount").toString()), 6));
				map.put("recp_amount", map.get("recp_amount")==null?"":ParseNumber.toStrDecimal(ParseNumber.toDouble(map.get("recp_amount").toString()), 6));
				map.put("del_ratio", map.get("del_ratio")==null?"":ParseNumber.toStrDecimal(ParseNumber.toDouble(map.get("del_ratio").toString()) * 100, 6) + "%");
				map.put("ret_ratio", map.get("ret_ratio")==null?"":ParseNumber.toStrDecimal(ParseNumber.toDouble(map.get("ret_ratio").toString()) * 100, 6) + "%");
				map.put("recp_ratio", map.get("recp_ratio")==null?"":ParseNumber.toStrDecimal(ParseNumber.toDouble(map.get("recp_ratio").toString()) * 100, 6) + "%");
			}
		}
		
		//前七个季度总体情况
		List<Map<String, Object>> list = anaDruginfoDao.getAnaChartByAllSea();
		String yTime = "[";//图表y轴时间
		String totalBasic = "[";//西药采购金额
		String proBasic = "[";//西药采购数量
		String total = "[";//中药采购金额
		String pro = "[";//中药采购数量
		Map<String, Object> dateMap = new HashMap<String, Object>();
		//循环解析数据
		for(int i =0;i<list.size();i++) {
			Map<String, Object> map = list.get(i);
			int drugCat = Integer.parseInt(map.get("drug_cat")+"");
			if(dateMap.size() == 0) {
				dateMap.put("date", map.get("date"));
				if(drugCat == 1) {
					dateMap.put("total_amount", map.get("total_amount"));
					dateMap.put("pro_count", map.get("pro_count"));
					dateMap.put("total2", 0);
					dateMap.put("pro2", 0);
				}else {
					dateMap.put("total_amount", 0);
					dateMap.put("pro_count", 0);
					dateMap.put("total2", map.get("total_amount"));
					dateMap.put("pro2", map.get("pro_count"));
				}
			}else if(dateMap.get("date").equals(map.get("date"))){
				if(drugCat == 1) {
					dateMap.put("total_amount", Double.parseDouble(map.get("total_amount")+"")+Double.parseDouble(dateMap.get("total_amount")+""));
					dateMap.put("pro_count", Double.parseDouble(map.get("pro_count")+"")+Double.parseDouble(dateMap.get("pro_count")+""));
				}else {
					dateMap.put("total2", Double.parseDouble(map.get("total_amount")+"")+Double.parseDouble(dateMap.get("total2")+""));
					dateMap.put("pro2", Double.parseDouble(map.get("pro_count")+"")+Double.parseDouble(dateMap.get("pro2")+""));
				}
			}else {
				String yTimeStr = String.valueOf(dateMap.get("date"));
				if(!"".equals(yTimeStr) && !"null".equals(yTimeStr)) {
					yTimeStr = yTimeStr.toString().substring(0, 4)+"年"+yTimeStr.toString().substring(4, 6)+"季度";
				}
				
				yTime = yTime +"'"+yTimeStr+ "',";
				String total_amountStr = dateMap.get("total_amount")+"";
				if("null".equals(total_amountStr)) {
					total_amountStr = "";
				}
				totalBasic = totalBasic + total_amountStr + ",";
				String pro_countStr = dateMap.get("pro_count")+"";
				if("null".equals(pro_countStr)) {
					pro_countStr = "";
				}
				proBasic = proBasic + pro_countStr+ ",";
				String total2Str = dateMap.get("total2")+"";
				if("null".equals(total2Str)) {
					total2Str = "";
				}
				total = total + total2Str + ",";
				String pro2Str = dateMap.get("pro2")+"";
				if("null".equals(pro2Str)) {
					pro2Str = "";
				}
				pro = pro + pro2Str+ ",";
				dateMap.clear();
				
				dateMap.put("date", map.get("date"));
				if(drugCat == 1) {
					dateMap.put("total_amount", map.get("total_amount"));
					dateMap.put("pro_count", map.get("pro_count"));
					dateMap.put("total2", 0);
					dateMap.put("pro2", 0);
				}else {
					dateMap.put("total_amount", 0);
					dateMap.put("pro_count", 0);
					dateMap.put("total2", map.get("total_amount"));
					dateMap.put("pro2", map.get("pro_count"));
				}
			}
		}
		
		if(!"[".equals(yTime)) {//判断是否为空
			yTime = yTime.substring(0, yTime.length()-1) + "]";
			totalBasic = totalBasic.substring(0, totalBasic.length()-1) + "]";
			proBasic = proBasic.substring(0, proBasic.length()-1) + "]";
			total = total.substring(0, total.length()-1) + "]";
			pro = pro.substring(0, pro.length()-1) + "]";
			
			anaTotal.getConditions().put("yTime", yTime);
			anaTotal.getConditions().put("totalBasic", totalBasic);
			anaTotal.getConditions().put("proBasic", proBasic);
			anaTotal.getConditions().put("total", total);
			anaTotal.getConditions().put("pro", pro);
		}
		
		return anaTotal;
	}
	
	/**
	 * @category 采购总体情况汇总信息（年度）
	 * @date 2015年12月22日
	 * @author lil
	 * @param page
	 * @return
	 */
	@SuppressWarnings("unchecked")
	@Override
	public Pagination getAnaByAllYear(Pagination page) {
		
		//总体采购情况
		Pagination anaTotal = anaDruginfoDao.getAnaByAllYear(page);
		List<Map<String, Object>> listPage = (List<Map<String, Object>>) page.getRows();
		if (null != listPage && listPage.size() > 0){
			for (int i = 0; i < listPage.size(); i++){
				Map<String, Object> map = listPage.get(i);
				map.put("total_amount", map.get("total_amount")==null?"":ParseNumber.toStrDecimal(ParseNumber.toDouble(map.get("total_amount").toString()), 6));
				map.put("del_amount", map.get("del_amount")==null?"":ParseNumber.toStrDecimal(ParseNumber.toDouble(map.get("del_amount").toString()), 6));
				map.put("ret_amount", map.get("ret_amount")==null?"":ParseNumber.toStrDecimal(ParseNumber.toDouble(map.get("ret_amount").toString()), 6));
				map.put("recp_amount", map.get("recp_amount")==null?"":ParseNumber.toStrDecimal(ParseNumber.toDouble(map.get("recp_amount").toString()), 6));
				map.put("del_ratio", map.get("del_ratio")==null?"":ParseNumber.toStrDecimal(ParseNumber.toDouble(map.get("del_ratio").toString()) * 100, 6) + "%");
				map.put("ret_ratio", map.get("ret_ratio")==null?"":ParseNumber.toStrDecimal(ParseNumber.toDouble(map.get("ret_ratio").toString()) * 100, 6) + "%");
				map.put("recp_ratio", map.get("recp_ratio")==null?"":ParseNumber.toStrDecimal(ParseNumber.toDouble(map.get("recp_ratio").toString()) * 100, 6) + "%");
			}
		}
		
		
		//前七年总体采购情况
		List<Map<String, Object>> list = anaDruginfoDao.getAnaChartByAllYear();
		String yTime = "[";//图表y轴时间
		String totalBasic = "[";//西药采购金额
		String proBasic = "[";//西药采购数量
		String total = "[";//中药采购金额
		String pro = "[";//中药采购数量
		Map<String, Object> dateMap = new HashMap<String, Object>();
		//循环解析数据
		for(int i =0;i<list.size();i++) {
			Map<String, Object> map = list.get(i);
			int drugCat = Integer.parseInt(map.get("drug_cat")+"");
			if(dateMap.size() == 0) {
				dateMap.put("date", map.get("date"));
				if(drugCat == 1) {
					dateMap.put("total_amount", map.get("total_amount"));
					dateMap.put("pro_count", map.get("pro_count"));
					dateMap.put("total2", 0);
					dateMap.put("pro2", 0);
				}else {
					dateMap.put("total_amount", 0);
					dateMap.put("pro_count", 0);
					dateMap.put("total2", map.get("total_amount"));
					dateMap.put("pro2", map.get("pro_count"));
				}
			}else if(dateMap.get("date").equals(map.get("date"))){
				if(drugCat == 1) {
					dateMap.put("total_amount", Double.parseDouble(map.get("total_amount")+"")+Double.parseDouble(dateMap.get("total_amount")+""));
					dateMap.put("pro_count", Double.parseDouble(map.get("pro_count")+"")+Double.parseDouble(dateMap.get("pro_count")+""));
				}else {
					dateMap.put("total2", Double.parseDouble(map.get("total_amount")+"")+Double.parseDouble(dateMap.get("total2")+""));
					dateMap.put("pro2", Double.parseDouble(map.get("pro_count")+"")+Double.parseDouble(dateMap.get("pro2")+""));
				}
			}else {
				String yTimeStr = String.valueOf(dateMap.get("date"));
				if(!"".equals(yTimeStr) && !"null".equals(yTimeStr)) {
					yTimeStr = yTimeStr.toString()+ "年";
				}
				
				yTime = yTime +"'"+yTimeStr+ "',";
				String total_amountStr = dateMap.get("total_amount")+"";
				if("null".equals(total_amountStr)) {
					total_amountStr = "";
				}
				totalBasic = totalBasic + total_amountStr + ",";
				String pro_countStr = dateMap.get("pro_count")+"";
				if("null".equals(pro_countStr)) {
					pro_countStr = "";
				}
				proBasic = proBasic + pro_countStr+ ",";
				String total2Str = dateMap.get("total2")+"";
				if("null".equals(total2Str)) {
					total2Str = "";
				}
				total = total + total2Str + ",";
				String pro2Str = dateMap.get("pro2")+"";
				if("null".equals(pro2Str)) {
					pro2Str = "";
				}
				pro = pro + pro2Str+ ",";
				dateMap.clear();
				
				dateMap.put("date", map.get("date"));
				if(drugCat == 1) {
					dateMap.put("total_amount", map.get("total_amount"));
					dateMap.put("pro_count", map.get("pro_count"));
					dateMap.put("total2", 0);
					dateMap.put("pro2", 0);
				}else {
					dateMap.put("total_amount", 0);
					dateMap.put("pro_count", 0);
					dateMap.put("total2", map.get("total_amount"));
					dateMap.put("pro2", map.get("pro_count"));
				}
			}
		}
		
		if(!"[".equals(yTime)) {//判断是否为空
			yTime = yTime.substring(0, yTime.length()-1) + "]";
			totalBasic = totalBasic.substring(0, totalBasic.length()-1) + "]";
			proBasic = proBasic.substring(0, proBasic.length()-1) + "]";
			total = total.substring(0, total.length()-1) + "]";
			pro = pro.substring(0, pro.length()-1) + "]";
			
			anaTotal.getConditions().put("yTime", yTime);
			anaTotal.getConditions().put("totalBasic", totalBasic);
			anaTotal.getConditions().put("proBasic", proBasic);
			anaTotal.getConditions().put("total", total);
			anaTotal.getConditions().put("pro", pro);
		}
		
		return anaTotal;
	}
	
	/**
	 * @category 按企业统计(日)
	 * @date 2015年12月1日10:55:55
	 * @return
	 */
	@SuppressWarnings("unchecked")
	@Override
	public Pagination getAnaByComp(Pagination page) {
		List<Map<String,Object>> list = (List<Map<String, Object>>) anaDruginfoDao.getAnaByComp(page).getRows();
		for(Map<String,Object> data : list){
			Object base_ratio = data.get("base_ratio");
			Object ret_ratio = data.get("ret_ratio");
			Object date = data.get("date");
			data.put("date", date==null?"":date.toString().substring(0, 4)+"-"+date.toString().substring(4, 6)+"-"+date.toString().substring(6, 8));
			data.put("base_ratio", base_ratio==null?"":ParseNumber.toStrDecimal(Double.parseDouble(base_ratio.toString())*100,6)+"%");
			data.put("ret_ratio", ret_ratio==null?"":ParseNumber.toStrDecimal(Double.parseDouble(ret_ratio.toString())*100,6)+"%");
		}
		
		//获取药品采购总量月汇总集合
		List<Map<String, Object>> totalList = (List<Map<String, Object>>) anaDruginfoDao.getAnaTotalByCompYesterday();
		String yTime = "[";//图表y轴时间
		String total = "[";//采购金额
		String del = "[";//配送金额
		String ret = "[";//退货金额
		String date = DateUtil.date(new Timestamp(System.currentTimeMillis()-1000 * 60 * 60 * 24)).replaceAll("-", "");
		//循环解析数据
		for(int i =0;i<totalList.size();i++) {
			Map<String, Object> map = totalList.get(i);
			String hospName =  map.get("del_comp_name").toString();
			yTime = yTime +"'"+hospName+ "',";
			total = total + map.get("total_amount") + ",";
			del = del + map.get("del_amount") + ",";
			ret = ret + map.get("ret_amount") + ",";
		}
		
		if(!"[".equals(yTime)) {//判断是否为空
			yTime = yTime.substring(0, yTime.length()-1) + "]";
			total = total.substring(0, total.length()-1) + "]";
			del = del.substring(0, del.length()-1) + "]";
			ret = ret.substring(0, ret.length()-1) + "]";
			
			page.getConditions().put("yTime", yTime);
			page.getConditions().put("total", total);
			page.getConditions().put("del", del);
			page.getConditions().put("ret", ret);
		}		
		page.getConditions().put("chartTitle", date+"企业采购统计");	
		return page;
	}
	
	/**
	 * @category 按企业统计(年)
	 * @date 2015年12月1日10:55:55
	 * @return
	 */
	@SuppressWarnings("unchecked")
	@Override
	public Pagination getYearAnaByComp(Pagination page) {
		List<Map<String,Object>> list = (List<Map<String, Object>>) anaDruginfoDao.getYearAnaByComp(page).getRows();
		for(Map<String,Object> data : list){
			Object total_amount = data.get("total_amount");
			Object western_amount = data.get("western_amount");
			Object eastern_amount = data.get("eastern_amount");
			Object del_amount = data.get("del_amount");
			Object recp_amount = data.get("recp_amount");
			Object eastern_ratio = data.get("eastern_ratio");
			Object del_ratio = data.get("del_ratio");
			Object recp_ratio = data.get("recp_ratio");
			Object ret_ratio = data.get("ret_ratio");
			Object date = data.get("date");
			data.put("date", date==null?"":date.toString()+"年");
			data.put("total_amount", total_amount==null?"":ParseNumber.toStrDecimal(ParseNumber.toDouble(total_amount.toString()), 6));
			data.put("western_amount", western_amount==null?"":ParseNumber.toStrDecimal(ParseNumber.toDouble(western_amount.toString()), 6));
			data.put("eastern_amount", eastern_amount==null?"":ParseNumber.toStrDecimal(ParseNumber.toDouble(eastern_amount.toString()), 6));
			data.put("del_amount", del_amount==null?"":ParseNumber.toStrDecimal(ParseNumber.toDouble(del_amount.toString()), 6));
			data.put("recp_amount", recp_amount==null?"":ParseNumber.toStrDecimal(ParseNumber.toDouble(recp_amount.toString()), 6));
			data.put("eastern_ratio", eastern_ratio==null?"":ParseNumber.toStrDecimal(Double.parseDouble(eastern_ratio.toString())*100,6)+"%");
			data.put("del_ratio", del_ratio==null?"":ParseNumber.toStrDecimal(Double.parseDouble(del_ratio.toString())*100,6)+"%");
			data.put("recp_ratio", recp_ratio==null?"":ParseNumber.toStrDecimal(Double.parseDouble(recp_ratio.toString())*100,6)+"%");
			data.put("ret_ratio", ret_ratio==null?"":ParseNumber.toStrDecimal(Double.parseDouble(ret_ratio.toString())*100,6)+"%");
		}
		
		//获取药品采购总量月汇总集合
		List<Map<String, Object>> totalList = (List<Map<String, Object>>) anaDruginfoDao.getAnaTotalByCompLastYear(page);
		String yComp = "[";//图表y轴时间
		String total = "[";//采购金额
		//循环解析数据
		for(int i =0;i<totalList.size();i++) {
			Map<String, Object> map = totalList.get(i);
			String hospName =  map.get("del_comp_name").toString();
			yComp = yComp +"'"+hospName+ "',";
			total = total + map.get("total_amount") + ",";
		}
		
		if(!"[".equals(yComp)) {//判断是否为空
			yComp = yComp.substring(0, yComp.length()-1) + "]";
			total = total.substring(0, total.length()-1) + "]";
			
			page.getConditions().put("yComp", yComp);
			page.getConditions().put("total", total);
		}
		return page;
				
	}
	
	/**
	 * @category 按企业统计(季度)
	 * @date 2015年12月1日10:55:55
	 * @return
	 */
	@SuppressWarnings("unchecked")
	@Override
	public Pagination getSeaAnaByComp(Pagination page) {
		List<Map<String,Object>> list = (List<Map<String, Object>>) anaDruginfoDao.getSeaAnaByComp(page).getRows();
		for(Map<String,Object> data : list){
			Object total_amount = data.get("total_amount");
			Object western_amount = data.get("western_amount");
			Object eastern_amount = data.get("eastern_amount");
			Object del_amount = data.get("del_amount");
			Object recp_amount = data.get("recp_amount");
			Object eastern_ratio = data.get("eastern_ratio");
			Object del_ratio = data.get("del_ratio");
			Object recp_ratio = data.get("recp_ratio");
			Object ret_ratio = data.get("ret_ratio");
			Object date = data.get("date");
			data.put("date", date==null?"":date.toString().substring(0, 4)+"年"+date.toString().substring(4, 6)+"季度");
			data.put("total_amount", total_amount==null?"":ParseNumber.toStrDecimal(ParseNumber.toDouble(total_amount.toString()), 6));
			data.put("western_amount", western_amount==null?"":ParseNumber.toStrDecimal(ParseNumber.toDouble(western_amount.toString()), 6));
			data.put("eastern_amount", eastern_amount==null?"":ParseNumber.toStrDecimal(ParseNumber.toDouble(eastern_amount.toString()), 6));
			data.put("del_amount", del_amount==null?"":ParseNumber.toStrDecimal(ParseNumber.toDouble(del_amount.toString()), 6));
			data.put("recp_amount", recp_amount==null?"":ParseNumber.toStrDecimal(ParseNumber.toDouble(recp_amount.toString()), 6));
			data.put("eastern_ratio", eastern_ratio==null?"":ParseNumber.toStrDecimal(Double.parseDouble(eastern_ratio.toString())*100,6)+"%");
			data.put("del_ratio", del_ratio==null?"":ParseNumber.toStrDecimal(Double.parseDouble(del_ratio.toString())*100,6)+"%");
			data.put("recp_ratio", recp_ratio==null?"":ParseNumber.toStrDecimal(Double.parseDouble(recp_ratio.toString())*100,6)+"%");
			data.put("ret_ratio", ret_ratio==null?"":ParseNumber.toStrDecimal(Double.parseDouble(ret_ratio.toString())*100,6)+"%");
		}
		//获取药品采购总量月汇总集合
		List<Map<String, Object>> totalList = (List<Map<String, Object>>) anaDruginfoDao.getAnaTotalByCompLastQuarter(page);
		String yComp = "[";//图表y轴时间
		String total = "[";//采购金额
		//循环解析数据
		for(int i =0;i<totalList.size();i++) {
			Map<String, Object> map = totalList.get(i);
			String hospName =  map.get("del_comp_name").toString();
			yComp = yComp +"'"+hospName+ "',";
			total = total + map.get("total_amount") + ",";
		}
		
		if(!"[".equals(yComp)) {//判断是否为空
			yComp = yComp.substring(0, yComp.length()-1) + "]";
			total = total.substring(0, total.length()-1) + "]";
			
			page.getConditions().put("yComp", yComp);
			page.getConditions().put("total", total);
		}
		return page;
	}
	
	/**
	 * @category 按企业统计(月)
	 * @date 2015年12月1日10:55:55
	 * @return
	 */
	@SuppressWarnings("unchecked")
	@Override
	public Pagination getMonthAnaByComp(Pagination page) {
		List<Map<String,Object>> list = (List<Map<String, Object>>) anaDruginfoDao.getMonthAnaByComp(page).getRows();
		for(Map<String,Object> data : list){
			Object total_amount = data.get("total_amount");
			Object western_amount = data.get("western_amount");
			Object eastern_amount = data.get("eastern_amount");
			Object del_amount = data.get("del_amount");
			Object recp_amount = data.get("recp_amount");
			Object eastern_ratio = data.get("eastern_ratio");
			Object del_ratio = data.get("del_ratio");
			Object recp_ratio = data.get("recp_ratio");
			Object ret_ratio = data.get("ret_ratio");
			//Object date = data.get("date");
			//data.put("date", date==null?"":date.toString().substring(0, 4)+"-"+date.toString().substring(4, 6));
			data.put("total_amount", total_amount==null?"":ParseNumber.toStrDecimal(ParseNumber.toDouble(total_amount.toString()), 6));
			data.put("western_amount", western_amount==null?"":ParseNumber.toStrDecimal(ParseNumber.toDouble(western_amount.toString()), 6));
			data.put("eastern_amount", eastern_amount==null?"":ParseNumber.toStrDecimal(ParseNumber.toDouble(eastern_amount.toString()), 6));
			data.put("del_amount", del_amount==null?"":ParseNumber.toStrDecimal(ParseNumber.toDouble(del_amount.toString()), 6));
			data.put("recp_amount", recp_amount==null?"":ParseNumber.toStrDecimal(ParseNumber.toDouble(recp_amount.toString()), 6));
			data.put("eastern_ratio", eastern_ratio==null?"":ParseNumber.toStrDecimal(Double.parseDouble(eastern_ratio.toString())*100,6)+"%");
			data.put("del_ratio", del_ratio==null?"":ParseNumber.toStrDecimal(Double.parseDouble(del_ratio.toString())*100,6)+"%");
			data.put("recp_ratio", recp_ratio==null?"":ParseNumber.toStrDecimal(Double.parseDouble(recp_ratio.toString())*100,6)+"%");
			data.put("ret_ratio", ret_ratio==null?"":ParseNumber.toStrDecimal(Double.parseDouble(ret_ratio.toString())*100,6)+"%");
			if (StringUtils.isNotBlank(page.getConditions().get("startMonth")) && !StringUtils.isNotBlank(page.getConditions().get("endMonth"))){
//				data.put("date", page.getConditions().get("startMonth").replaceAll("-", "")+"-"+ParseDate.parseDateToYm(ParseDate.addMonth(new Date(), -1)).replaceAll("-", ""));
				data.put("date", page.getConditions().get("startMonth").replaceAll("-", "")+"-"+ParseDate.parseDateToYm(new Date()));
			}else if (StringUtils.isNotBlank(page.getConditions().get("startMonth")) && StringUtils.isNotBlank(page.getConditions().get("endMonth"))){
				data.put("date", page.getConditions().get("startMonth").replaceAll("-", "")+"-"+page.getConditions().get("endMonth").replaceAll("-", ""));
			}
		}
		return page;
	}
	
	/**
	 * @category 首页的柱状图数据
	 * @date 2015年12月1日10:55:55
	 * @return
	 */
	@SuppressWarnings("unchecked")
	@Override
	public Pagination getHomeChartData(Pagination page) {
		List<Map<String, Object>> totalList = (List<Map<String, Object>>) anaDruginfoDao.getHomeChartData();
		String yTime = "[";//图表y轴时间
		String total = "[";//采购金额
		String del = "[";//配送金额
		String ret = "[";//退货金额
		//循环解析数据
		for(int i =0;i<totalList.size();i++) {
			Map<String, Object> map = totalList.get(i);
			String isBasic = map.get("is_basic")==null?"":"1".equals(map.get("is_basic").toString())?"基药":"非基药 ";
			String date =  map.get("date").toString();
			yTime = yTime +"'"+date+isBasic+ "',";
			total = total + map.get("total_amount") + ",";
			del = del + map.get("del_amount") + ",";
			ret = ret + map.get("ret_amount") + ",";
		}
		
		if(!"[".equals(yTime)) {//判断是否为空
			yTime = yTime.substring(0, yTime.length()-1) + "]";
			total = total.substring(0, total.length()-1) + "]";
			del = del.substring(0, del.length()-1) + "]";
			ret = ret.substring(0, ret.length()-1) + "]";
			
			page.getConditions().put("yTime", yTime);
			page.getConditions().put("total", total);
			page.getConditions().put("del", del);
			page.getConditions().put("ret", ret);
		}	
		return page;
	}

	
	@SuppressWarnings("unchecked")
	@Override
	public Pagination getAnaByDrugsSeaNoPage(Pagination page) {
		List<Map<String, Object>> list = (List<Map<String, Object>>) anaDruginfoDao.getAnaByDrugsSeaNoPage(page).getRows();
		formatAna(list);
		return page;
	}


	@SuppressWarnings("unchecked")
	@Override
	public Pagination getAnaByDrugsYearNoPage(Pagination page) {
		List<Map<String, Object>> list = (List<Map<String, Object>>) anaDruginfoDao.getAnaByDrugsYearNoPage(page).getRows();
		formatAna(list);
		return page;
	}
	
	/**
	 * @category 采购总体情况汇总信息无分页（月度）
	 * @date 2015年12月22日
	 * @author lil
	 * @param page
	 * @return
	 */
	@SuppressWarnings("unchecked")
	@Override
	public Pagination getAnaByAllMonthNoPage(Pagination page) {
		
		List<Map<String, Object>> list = (List<Map<String, Object>>) anaDruginfoDao.getAnaByAllMonthNoPage(page).getRows();
		for (int i = 0; i < list.size(); i++){
				Map<String, Object> map = list.get(i);
				String drugCat = String.valueOf(map.get("drug_cat"));
				map.put("drug_cat", drugCat.equals("null")?"其他":(drugCat.equals("1")?"西药":"中药"));
				map.put("total_amount", map.get("total_amount")==null?"":ParseNumber.toStrDecimal(ParseNumber.toDouble(map.get("total_amount").toString()), 6));
				map.put("del_amount", map.get("del_amount")==null?"":ParseNumber.toStrDecimal(ParseNumber.toDouble(map.get("del_amount").toString()), 6));
				map.put("ret_amount", map.get("ret_amount")==null?"":ParseNumber.toStrDecimal(ParseNumber.toDouble(map.get("ret_amount").toString()), 6));
				map.put("recp_amount", map.get("recp_amount")==null?"":ParseNumber.toStrDecimal(ParseNumber.toDouble(map.get("recp_amount").toString()), 6));
				map.put("del_ratio", map.get("del_ratio")==null?"":ParseNumber.toStrDecimal(ParseNumber.toDouble(map.get("del_ratio").toString()) * 100, 6) + "%");
				map.put("ret_ratio", map.get("ret_ratio")==null?"":ParseNumber.toStrDecimal(ParseNumber.toDouble(map.get("ret_ratio").toString()) * 100, 6) + "%");
				map.put("recp_ratio", map.get("recp_ratio")==null?"":ParseNumber.toStrDecimal(ParseNumber.toDouble(map.get("recp_ratio").toString()) * 100, 6) + "%");
				
				if (StringUtils.isNotBlank(page.getConditions().get("starttime")) && !StringUtils.isNotBlank(page.getConditions().get("endtime"))){
//					map.put("date", page.getConditions().get("starttime")+"-"+ParseDate.parseDateToYm(ParseDate.addMonth(new Date(), -1)));
					map.put("date", page.getConditions().get("starttime")+"-"+ParseDate.parseDateToYm(new Date()));
				}else if (StringUtils.isNotBlank(page.getConditions().get("starttime")) && StringUtils.isNotBlank(page.getConditions().get("endtime"))){
					map.put("date", page.getConditions().get("starttime")+"-"+page.getConditions().get("endtime"));
				}
		}
		return page;
	}
	
	/**
	 * @category 采购总体情况汇总信息无分页（季度）
	 * @date 2015年12月22日
	 * @author lil
	 * @param page
	 * @return
	 */
	@SuppressWarnings("unchecked")
	@Override
	public Pagination getAnaByAllSeaNoPage(Pagination page) {
		
		List<Map<String, Object>> list = (List<Map<String, Object>>) anaDruginfoDao.getAnaByAllSeaNoPage(page).getRows();
		for (int i = 0; i < list.size(); i++){
				Map<String, Object> map = list.get(i);
				String drugCat = String.valueOf(map.get("drug_cat"));
				map.put("drug_cat", drugCat.equals("null")?"其他":(drugCat.equals("1")?"西药":"中药"));
				map.put("total_amount", map.get("total_amount")==null?"":ParseNumber.toStrDecimal(ParseNumber.toDouble(map.get("total_amount").toString()), 6));
				map.put("del_amount", map.get("del_amount")==null?"":ParseNumber.toStrDecimal(ParseNumber.toDouble(map.get("del_amount").toString()), 6));
				map.put("ret_amount", map.get("ret_amount")==null?"":ParseNumber.toStrDecimal(ParseNumber.toDouble(map.get("ret_amount").toString()), 6));
				map.put("recp_amount", map.get("recp_amount")==null?"":ParseNumber.toStrDecimal(ParseNumber.toDouble(map.get("recp_amount").toString()), 6));
				map.put("del_ratio", map.get("del_ratio")==null?"":ParseNumber.toStrDecimal(ParseNumber.toDouble(map.get("del_ratio").toString()) * 100, 6) + "%");
				map.put("ret_ratio", map.get("ret_ratio")==null?"":ParseNumber.toStrDecimal(ParseNumber.toDouble(map.get("ret_ratio").toString()) * 100, 6) + "%");
				map.put("recp_ratio", map.get("recp_ratio")==null?"":ParseNumber.toStrDecimal(ParseNumber.toDouble(map.get("recp_ratio").toString()) * 100, 6) + "%");
		}
		return page;
	}
	
	/**
	 * @category 采购总体情况汇总信息无分页（年度）
	 * @date 2015年12月22日
	 * @author lil
	 * @param page
	 * @return
	 */
	@SuppressWarnings("unchecked")
	@Override
	public Pagination getAnaByAllYearNoPage(Pagination page) {
		
		List<Map<String, Object>> list = (List<Map<String, Object>>) anaDruginfoDao.getAnaByAllYearNoPage(page).getRows();
		for (int i = 0; i < list.size(); i++){
				Map<String, Object> map = list.get(i);
				String drugCat = String.valueOf(map.get("drug_cat"));
				map.put("drug_cat", drugCat.equals("null")?"其他":(drugCat.equals("1")?"西药":"中药"));
				map.put("total_amount", map.get("total_amount")==null?"":ParseNumber.toStrDecimal(ParseNumber.toDouble(map.get("total_amount").toString()), 6));
				map.put("del_amount", map.get("del_amount")==null?"":ParseNumber.toStrDecimal(ParseNumber.toDouble(map.get("del_amount").toString()), 6));
				map.put("ret_amount", map.get("ret_amount")==null?"":ParseNumber.toStrDecimal(ParseNumber.toDouble(map.get("ret_amount").toString()), 6));
				map.put("recp_amount", map.get("recp_amount")==null?"":ParseNumber.toStrDecimal(ParseNumber.toDouble(map.get("recp_amount").toString()), 6));
				map.put("del_ratio", map.get("del_ratio")==null?"":ParseNumber.toStrDecimal(ParseNumber.toDouble(map.get("del_ratio").toString()) * 100, 6) + "%");
				map.put("ret_ratio", map.get("ret_ratio")==null?"":ParseNumber.toStrDecimal(ParseNumber.toDouble(map.get("ret_ratio").toString()) * 100, 6) + "%");
				map.put("recp_ratio", map.get("recp_ratio")==null?"":ParseNumber.toStrDecimal(ParseNumber.toDouble(map.get("recp_ratio").toString()) * 100, 6) + "%");
		}
		return page;
	}
	
	
	/**
	 * @category 按企业统计无分页(年)
	 * @date 2015年12月1日10:55:55
	 * @return
	 */
	@SuppressWarnings("unchecked")
	@Override
	public Pagination getYearAnaByCompNoPage(Pagination page) {
		List<Map<String,Object>> list = (List<Map<String, Object>>) anaDruginfoDao.getYearAnaByCompNoPage(page).getRows();
		for(Map<String,Object> data : list){
			Object total_amount = data.get("total_amount");
			Object western_amount = data.get("western_amount");
			Object eastern_amount = data.get("eastern_amount");
			Object del_amount = data.get("del_amount");
			Object recp_amount = data.get("recp_amount");
			Object eastern_ratio = data.get("eastern_ratio");
			Object del_ratio = data.get("del_ratio");
			Object recp_ratio = data.get("recp_ratio");
			Object ret_ratio = data.get("ret_ratio");
			Object date = data.get("date");
			data.put("date", date==null?"":date.toString()+"年");
			data.put("total_amount", total_amount==null?"":ParseNumber.toStrDecimal(ParseNumber.toDouble(total_amount.toString()), 6));
			data.put("western_amount", western_amount==null?"":ParseNumber.toStrDecimal(ParseNumber.toDouble(western_amount.toString()), 6));
			data.put("eastern_amount", eastern_amount==null?"":ParseNumber.toStrDecimal(ParseNumber.toDouble(eastern_amount.toString()), 6));
			data.put("del_amount", del_amount==null?"":ParseNumber.toStrDecimal(ParseNumber.toDouble(del_amount.toString()), 6));
			data.put("recp_amount", recp_amount==null?"":ParseNumber.toStrDecimal(ParseNumber.toDouble(recp_amount.toString()), 6));
			data.put("eastern_ratio", eastern_ratio==null?"":ParseNumber.toStrDecimal(Double.parseDouble(eastern_ratio.toString())*100,6)+"%");
			data.put("del_ratio", del_ratio==null?"":ParseNumber.toStrDecimal(Double.parseDouble(del_ratio.toString())*100,6)+"%");
			data.put("recp_ratio", recp_ratio==null?"":ParseNumber.toStrDecimal(Double.parseDouble(recp_ratio.toString())*100,6)+"%");
			data.put("ret_ratio", ret_ratio==null?"":ParseNumber.toStrDecimal(Double.parseDouble(ret_ratio.toString())*100,6)+"%");
		}
		return page;
				
	}
	
	/**
	 * @category 按企业统计无分页(季度)
	 * @date 2015年12月1日10:55:55
	 * @return
	 */
	@SuppressWarnings("unchecked")
	@Override
	public Pagination getSeaAnaByCompNoPage(Pagination page) {
		List<Map<String,Object>> list = (List<Map<String, Object>>) anaDruginfoDao.getSeaAnaByCompNoPage(page).getRows();
		for(Map<String,Object> data : list){
			Object total_amount = data.get("total_amount");
			Object western_amount = data.get("western_amount");
			Object eastern_amount = data.get("eastern_amount");
			Object del_amount = data.get("del_amount");
			Object recp_amount = data.get("recp_amount");
			Object eastern_ratio = data.get("eastern_ratio");
			Object del_ratio = data.get("del_ratio");
			Object recp_ratio = data.get("recp_ratio");
			Object ret_ratio = data.get("ret_ratio");
			Object date = data.get("date");
			data.put("date", date==null?"":date.toString().substring(0, 4)+"年"+date.toString().substring(4, 6)+"季度");
			data.put("total_amount", total_amount==null?"":ParseNumber.toStrDecimal(ParseNumber.toDouble(total_amount.toString()), 6));
			data.put("western_amount", western_amount==null?"":ParseNumber.toStrDecimal(ParseNumber.toDouble(western_amount.toString()), 6));
			data.put("eastern_amount", eastern_amount==null?"":ParseNumber.toStrDecimal(ParseNumber.toDouble(eastern_amount.toString()), 6));
			data.put("del_amount", del_amount==null?"":ParseNumber.toStrDecimal(ParseNumber.toDouble(del_amount.toString()), 6));
			data.put("recp_amount", recp_amount==null?"":ParseNumber.toStrDecimal(ParseNumber.toDouble(recp_amount.toString()), 6));
			data.put("eastern_ratio", eastern_ratio==null?"":ParseNumber.toStrDecimal(Double.parseDouble(eastern_ratio.toString())*100,6)+"%");
			data.put("del_ratio", del_ratio==null?"":ParseNumber.toStrDecimal(Double.parseDouble(del_ratio.toString())*100,6)+"%");
			data.put("recp_ratio", recp_ratio==null?"":ParseNumber.toStrDecimal(Double.parseDouble(recp_ratio.toString())*100,6)+"%");
			data.put("ret_ratio", ret_ratio==null?"":ParseNumber.toStrDecimal(Double.parseDouble(ret_ratio.toString())*100,6)+"%");
		}
		return page;
	}
	
	/**
	 * @category 按企业统计无分页(月)
	 * @date 2015年12月1日10:55:55
	 * @return
	 */
	@SuppressWarnings("unchecked")
	@Override
	public Pagination getMonthAnaByCompNoPage(Pagination page) {
		List<Map<String,Object>> list = (List<Map<String, Object>>) anaDruginfoDao.getMonthAnaByCompNoPage(page).getRows();
		for(Map<String,Object> data : list){
			Object total_amount = data.get("total_amount");
			Object western_amount = data.get("western_amount");
			Object eastern_amount = data.get("eastern_amount");
			Object del_amount = data.get("del_amount");
			Object recp_amount = data.get("recp_amount");
			Object eastern_ratio = data.get("eastern_ratio");
			Object del_ratio = data.get("del_ratio");
			Object recp_ratio = data.get("recp_ratio");
			Object ret_ratio = data.get("ret_ratio");
			Object date = data.get("date");
			data.put("date", date==null?"":date.toString().substring(0, 4)+"-"+date.toString().substring(4, 6));
			data.put("total_amount", total_amount==null?"":ParseNumber.toStrDecimal(ParseNumber.toDouble(total_amount.toString()), 6));
			data.put("western_amount", western_amount==null?"":ParseNumber.toStrDecimal(ParseNumber.toDouble(western_amount.toString()), 6));
			data.put("eastern_amount", eastern_amount==null?"":ParseNumber.toStrDecimal(ParseNumber.toDouble(eastern_amount.toString()), 6));
			data.put("del_amount", del_amount==null?"":ParseNumber.toStrDecimal(ParseNumber.toDouble(del_amount.toString()), 6));
			data.put("recp_amount", recp_amount==null?"":ParseNumber.toStrDecimal(ParseNumber.toDouble(recp_amount.toString()), 6));
			data.put("eastern_ratio", eastern_ratio==null?"":ParseNumber.toStrDecimal(Double.parseDouble(eastern_ratio.toString())*100,6)+"%");
			data.put("del_ratio", del_ratio==null?"":ParseNumber.toStrDecimal(Double.parseDouble(del_ratio.toString())*100,6)+"%");
			data.put("recp_ratio", recp_ratio==null?"":ParseNumber.toStrDecimal(Double.parseDouble(recp_ratio.toString())*100,6)+"%");
			data.put("ret_ratio", ret_ratio==null?"":ParseNumber.toStrDecimal(Double.parseDouble(ret_ratio.toString())*100,6)+"%");
		}
		return page;
	}




	@Override
	public Pagination getMonthAnaByHospNoPage(Pagination page) {
		List<Map<String, Object>> list =  anaDruginfoDao.getMonthAnaByHospNoPage(page);
		formatAna(list);
		page.setRows(list);
		return page;
	}


	@Override
	public Pagination getSeaAnaByHospNoPage(Pagination page) {
		List<Map<String, Object>> list =  anaDruginfoDao.getSeaAnaByHospNoPage(page);
		formatAna(list);
		page.setRows(list);
		return page;
	}


	@Override
	public Pagination getYearAnaByHospNoPage(Pagination page) {
		List<Map<String, Object>> list =  anaDruginfoDao.getYearAnaByHospNoPage(page);
		formatAna(list);
		page.setRows(list);
		return page;
	}
	
	/**
	 * @category 地区采购情况统计无分页(月)
	 * @date 2015年12月1日10:55:55
	 * @author lil
	 * @return
	 */		
	@SuppressWarnings("unchecked")
	public Pagination getAnaByAreaWithMonNoPage(Pagination page){
		page =  anaDruginfoDao.getAnaByAreaWithMonNoPage(page);
		List<Map<String, Object>> list = (List<Map<String, Object>>) page.getRows();
		if (null != list && list.size() > 0){
			for (int i = 0; i < list.size(); i++){
				Map<String, Object> map = list.get(i);
				map.put("total_amount", map.get("total_amount")==null?"":ParseNumber.toStrDecimal(ParseNumber.toDouble(map.get("total_amount").toString()), 6));
				map.put("western_amount", map.get("western_amount")==null?"":ParseNumber.toStrDecimal(ParseNumber.toDouble(map.get("western_amount").toString()), 6));
				map.put("eastern_amount", map.get("eastern_amount")==null?"":ParseNumber.toStrDecimal(ParseNumber.toDouble(map.get("eastern_amount").toString()), 6));
				map.put("del_amount", map.get("del_amount")==null?"":ParseNumber.toStrDecimal(ParseNumber.toDouble(map.get("del_amount").toString()), 6));
				map.put("recp_amount", map.get("recp_amount")==null?"":ParseNumber.toStrDecimal(ParseNumber.toDouble(map.get("recp_amount").toString()), 6));
				map.put("eastern_ratio", map.get("eastern_ratio")==null?"":ParseNumber.toStrDecimal(ParseNumber.toDouble(map.get("eastern_ratio").toString()) * 100, 6) + "%");
				map.put("del_ratio", map.get("del_ratio")==null?"":ParseNumber.toStrDecimal(ParseNumber.toDouble(map.get("del_ratio").toString()) * 100, 6) + "%");
				map.put("recp_ratio", map.get("recp_ratio")==null?"":ParseNumber.toStrDecimal(ParseNumber.toDouble(map.get("recp_ratio").toString()) * 100, 6) + "%");
				map.put("ret_ratio", map.get("ret_ratio")==null?"":ParseNumber.toStrDecimal(ParseNumber.toDouble(map.get("ret_ratio").toString()) * 100, 6) + "%");
				
				if (StringUtils.isNotBlank(page.getConditions().get("startMon")) && !StringUtils.isNotBlank(page.getConditions().get("endMon"))){
//					map.put("date", page.getConditions().get("startMon")+"-"+ParseDate.parseDateToYm(ParseDate.addMonth(new Date(), -1)));
					map.put("date", page.getConditions().get("startMon")+"-"+ParseDate.parseDateToYm(new Date()));
				}else if (StringUtils.isNotBlank(page.getConditions().get("startMon")) && StringUtils.isNotBlank(page.getConditions().get("endMon"))){
					map.put("date", page.getConditions().get("startMon")+"-"+page.getConditions().get("endMon"));
				}
			}
		}
		return page;
	}
	
	/**
	 * @category 地区采购情况统计无分页(季度)
	 * @date 2015年12月1日10:55:55
	 * @author lil
	 * @return
	 */
	@SuppressWarnings("unchecked")
	public Pagination getAnaByAreaWithSeaNoPage(Pagination page){
		page =  anaDruginfoDao.getAnaByAreaWithSeaNoPage(page);
		List<Map<String, Object>> list = (List<Map<String, Object>>) page.getRows();
		if (null != list && list.size() > 0){
			for (int i = 0; i < list.size(); i++){
				Map<String, Object> map = list.get(i);
				map.put("total_amount", map.get("total_amount")==null?"":ParseNumber.toStrDecimal(ParseNumber.toDouble(map.get("total_amount").toString()), 6));
				map.put("western_amount", map.get("western_amount")==null?"":ParseNumber.toStrDecimal(ParseNumber.toDouble(map.get("western_amount").toString()), 6));
				map.put("eastern_amount", map.get("eastern_amount")==null?"":ParseNumber.toStrDecimal(ParseNumber.toDouble(map.get("eastern_amount").toString()), 6));
				map.put("del_amount", map.get("del_amount")==null?"":ParseNumber.toStrDecimal(ParseNumber.toDouble(map.get("del_amount").toString()), 6));
				map.put("recp_amount", map.get("recp_amount")==null?"":ParseNumber.toStrDecimal(ParseNumber.toDouble(map.get("recp_amount").toString()), 6));
				map.put("eastern_ratio", map.get("eastern_ratio")==null?"":ParseNumber.toStrDecimal(ParseNumber.toDouble(map.get("eastern_ratio").toString()) * 100, 6) + "%");
				map.put("del_ratio", map.get("del_ratio")==null?"":ParseNumber.toStrDecimal(ParseNumber.toDouble(map.get("del_ratio").toString()) * 100, 6) + "%");
				map.put("recp_ratio", map.get("recp_ratio")==null?"":ParseNumber.toStrDecimal(ParseNumber.toDouble(map.get("recp_ratio").toString()) * 100, 6) + "%");
				map.put("ret_ratio", map.get("ret_ratio")==null?"":ParseNumber.toStrDecimal(ParseNumber.toDouble(map.get("ret_ratio").toString()) * 100, 6) + "%");
			}
		}
		return page;
	}
	
	/**
	 * @category 地区采购情况统计无分页(年度)
	 * @date 2015年12月1日10:55:55
	 * @author lil
	 * @return
	 */
	@SuppressWarnings("unchecked")
	public Pagination getAnaByAreaWithYearNoPage(Pagination page){
		page =  anaDruginfoDao.getAnaByAreaWithYearNoPage(page);
		List<Map<String, Object>> list = (List<Map<String, Object>>) page.getRows();
		if (null != list && list.size() > 0){
			for (int i = 0; i < list.size(); i++){
				Map<String, Object> map = list.get(i);
				map.put("total_amount", map.get("total_amount")==null?"":ParseNumber.toStrDecimal(ParseNumber.toDouble(map.get("total_amount").toString()), 6));
				map.put("western_amount", map.get("western_amount")==null?"":ParseNumber.toStrDecimal(ParseNumber.toDouble(map.get("western_amount").toString()), 6));
				map.put("eastern_amount", map.get("eastern_amount")==null?"":ParseNumber.toStrDecimal(ParseNumber.toDouble(map.get("eastern_amount").toString()), 6));
				map.put("del_amount", map.get("del_amount")==null?"":ParseNumber.toStrDecimal(ParseNumber.toDouble(map.get("del_amount").toString()), 6));
				map.put("recp_amount", map.get("recp_amount")==null?"":ParseNumber.toStrDecimal(ParseNumber.toDouble(map.get("recp_amount").toString()), 6));
				map.put("eastern_ratio", map.get("eastern_ratio")==null?"":ParseNumber.toStrDecimal(ParseNumber.toDouble(map.get("eastern_ratio").toString()) * 100, 6) + "%");
				map.put("del_ratio", map.get("del_ratio")==null?"":ParseNumber.toStrDecimal(ParseNumber.toDouble(map.get("del_ratio").toString()) * 100, 6) + "%");
				map.put("recp_ratio", map.get("recp_ratio")==null?"":ParseNumber.toStrDecimal(ParseNumber.toDouble(map.get("recp_ratio").toString()) * 100, 6) + "%");
				map.put("ret_ratio", map.get("ret_ratio")==null?"":ParseNumber.toStrDecimal(ParseNumber.toDouble(map.get("ret_ratio").toString()) * 100, 6) + "%");
			}
		}
		return page;
	}

	/**
	 * @category 医疗机构查看药品配送情况
	 * @date 2015年12月24日10:50:46
	 * @author yxc
	 * @param page.getConditions().get("time") = mon、sea、year  
	 * @param page.getConditions().get("Paging") 有值则需要加载图表
	 * @param page.getConditions().get("areaId") 卫生局端查看
	 * @param page.getConditions().get("starttime") 开始日期
	 * @param page.getConditions().get("endtime") 结束日期 
	 * @param page.getConditions().get("drugCat") 药品分类
	 * @return
	 */
	@SuppressWarnings("unchecked")
	@Override
	public Pagination getAnaHospdruginfoTotal(Pagination page) {
		//type 2药品3配送企业4生产企业
		String type = page.getConditions().get("type");
		String[] dateStr =  page.getConditions().get("date").split("-");
		boolean tag = false;
		if(dateStr.length==2){
			page.getConditions().put("starttime", dateStr[0]);
			page.getConditions().put("endtime", dateStr[1]);
			tag = true;
		}
		if("2".equals(type)){
			if(tag){
				page = anaDruginfoDao.getAnaHospdruginfoTotalByDrugPool(page);
			}else{
				page = anaDruginfoDao.getAnaHospdruginfoTotalByDrug(page);
			}
		}else if("3".equals(type)){
			//ana_hospital_comp_mon
			if(tag){
				page = anaDruginfoDao.getAnaHospitalCompMonPool(page);
			}else{
				page = anaDruginfoDao.getAnaHospitalCompMon(page);
			}
		}else if("4".equals(type)){
			 //ana_hospital_prodcomp_mon
			if(tag){
				page = anaDruginfoDao.getAnaHospitalProdcompMonPool(page);
			}else{
				page = anaDruginfoDao.getAnaHospitalProdcompMon(page);
			}
			
		}
		formatAna((List<Map<String,Object>>)page.getRows());
		return page;
	}
	/**
	 * @category   根据药品采购情况查看地区
	 * @date 2015年12月24日10:50:43
	 * @author yxc
	 * @param page.getConditions().get("time") = mon、sea、year  
	 * @param page.getConditions().get("Paging") 有值则需要加载图表
	 * @param page.getConditions().get("areaId") 卫生局端查看
	 * @param page.getConditions().get("starttime") 开始日期
	 * @param page.getConditions().get("endtime") 结束日期 
	 * @param page.getConditions().get("drugCat") 药品分类
	 * @return
	 */
	@SuppressWarnings("unchecked")
	@Override
	public Pagination getAnaAreadruginfoTotal(Pagination page) {
		String[] dateStr =  page.getConditions().get("date").split("-");
		if(dateStr.length==2){
			page.getConditions().put("starttime", dateStr[0]);
			page.getConditions().put("endtime", dateStr[1]);
			page = anaDruginfoDao.getAnaAreadruginfoTotalPool(page);
		}else{
			page = anaDruginfoDao.getAnaAreadruginfoTotal(page);
		}
		formatAna((List<Map<String,Object>>)page.getRows());
		return page;
	}

	/**
	 * @category   根据药品采购情况查看配送企业
	 * @date 2015年12月24日10:50:43
	 * @author yxc
	 * @param page.getConditions().get("time") = mon、sea、year  
	 * @param page.getConditions().get("Paging") 有值则需要加载图表
	 * @param page.getConditions().get("areaId") 卫生局端查看
	 * @param page.getConditions().get("starttime") 开始日期
	 * @param page.getConditions().get("endtime") 结束日期 
	 * @param page.getConditions().get("drugCat") 药品分类
	 * @return
	 */
	@SuppressWarnings("unchecked")
	@Override
	public Pagination getAnaDeldruginfoTotal(Pagination page) {
//		if("sea".equals(page.getConditions().get("time"))){
//			if(StringUtils.isNotBlank( page.getConditions().get("starttime"))){
//				page.getConditions().put("starttime", page.getConditions().get("starttime").replaceAll("年", "0").replaceAll("季度", ""));
//			}
//			if(StringUtils.isNotBlank( page.getConditions().get("endtime"))){
//				page.getConditions().put("endtime", page.getConditions().get("endtime").replaceAll("年", "0").replaceAll("季度", ""));			
//			}
//		}
		String[] dateStr =  page.getConditions().get("date").split("-");
		if(dateStr.length==2){
			page.getConditions().put("starttime", dateStr[0]);
			page.getConditions().put("endtime", dateStr[1]);
			page = anaDruginfoDao.getAnaDeldruginfoTotalPool(page);
		}else{
			page = anaDruginfoDao.getAnaDeldruginfoTotal(page);
		}
		formatAna((List<Map<String,Object>>)page.getRows());
		return page;
	}

	private void formatAna(List<Map<String,Object>> list){
	for(Map<String,Object> map : list){
		String hospClassify = String.valueOf(map.get("hosp_classify"));
		map.put("hosp_classify", hospClassify.equals("1")?"县级及县以上医疗机构":"基层医院");
		String drugCat = String.valueOf(map.get("drug_cat"));
		map.put("drug_cat", drugCat.equals("null")?"其他":(drugCat.equals("1")?"西药":"中药"));
		map.put("total_amount", map.get("total_amount")==null?"":ParseNumber.toStrDecimal(ParseNumber.toDouble(map.get("total_amount").toString())/10000, 6));
		map.put("western_amount", map.get("western_amount")==null?"":ParseNumber.toStrDecimal(ParseNumber.toDouble(map.get("western_amount").toString())/10000, 6));
		map.put("eastern_amount", map.get("eastern_amount")==null?"":ParseNumber.toStrDecimal(ParseNumber.toDouble(map.get("eastern_amount").toString())/10000, 6));
		map.put("eastern_ratio", map.get("eastern_ratio")==null?"":ParseNumber.toStrDecimal(ParseNumber.toDouble(map.get("eastern_ratio").toString()) * 100, 6) + "%");
		map.put("del_amount", map.get("del_amount")==null?"":ParseNumber.toStrDecimal(ParseNumber.toDouble(map.get("del_amount").toString())/10000, 6));
		map.put("del_ratio", map.get("del_ratio")==null?"":ParseNumber.toStrDecimal(ParseNumber.toDouble(map.get("del_ratio").toString()) * 100, 6) + "%");
		map.put("recp_amount", map.get("recp_amount")==null?"":ParseNumber.toStrDecimal(ParseNumber.toDouble(map.get("recp_amount").toString())/10000, 6));
		map.put("recp_ratio", map.get("recp_ratio")==null?"":ParseNumber.toStrDecimal(ParseNumber.toDouble(map.get("recp_ratio").toString()) * 100, 6) + "%");
	}
}

	/**
	 * @category 配送企业药品统计信息
	 * @date 2015年12月1日10:55:55
	 * @author lil
	 * @return
	 */
	@SuppressWarnings("unchecked")
	public Pagination getAnaDelByDrug(Pagination page, String type){
		page =  anaDruginfoDao.getAnaDelByDrug(page, type);
		List<Map<String, Object>> list = (List<Map<String, Object>>) page.getRows();
		if (null != list && list.size() > 0){
			for (int i = 0; i < list.size(); i++){
				Map<String, Object> map = list.get(i);
				Object drug_cat = map.get("drug_cat");
				map.put("drug_cat",drug_cat==null?"":"1".equals(drug_cat.toString())?"西药":"中药");
				map.put("total_amount", map.get("total_amount")==null?"":ParseNumber.toStrDecimal(ParseNumber.toDouble(map.get("total_amount").toString()), 6));
				map.put("del_amount", map.get("del_amount")==null?"":ParseNumber.toStrDecimal(ParseNumber.toDouble(map.get("del_amount").toString()), 6));
				map.put("recp_amount", map.get("recp_amount")==null?"":ParseNumber.toStrDecimal(ParseNumber.toDouble(map.get("recp_amount").toString()), 6));
				map.put("ret_amount", map.get("ret_amount")==null?"":ParseNumber.toStrDecimal(ParseNumber.toDouble(map.get("ret_amount").toString()), 6));
				map.put("del_ratio", map.get("del_ratio")==null?"":ParseNumber.toStrDecimal(ParseNumber.toDouble(map.get("del_ratio").toString()) * 100, 6) + "%");
				map.put("recp_ratio", map.get("recp_ratio")==null?"":ParseNumber.toStrDecimal(ParseNumber.toDouble(map.get("recp_ratio").toString()) * 100, 6) + "%");
				map.put("ret_ratio", map.get("ret_ratio")==null?"":ParseNumber.toStrDecimal(ParseNumber.toDouble(map.get("ret_ratio").toString()) * 100, 6) + "%");
			}
		}
		return page;
	}
	
	
	/**
	 * @category 地区采购情况跳转
	 * @date 2015年12月1日10:55:55
	 * @author lil
	 * @return
	 */
	@SuppressWarnings("unchecked")
	@Override
	public Pagination getAnaByAreaTz(Pagination page) {
		
		String date = page.getConditions().get("date");
		String type = page.getConditions().get("type");
		if(date.indexOf("-") >= 0) {
			page.getConditions().put("startDate", date.substring(0, date.indexOf("-")));
			page.getConditions().put("endDate", date.substring(date.indexOf("-")+1, date.length()));
		}else {
			page.getConditions().put("startDate", date);
			page.getConditions().put("endDate", date);
		}
		
		List<Map<String,Object>> list = (List<Map<String, Object>>) anaDruginfoDao.getAnaByAreaTz(page).getRows();
		for(Map<String,Object> data : list){
			Object total_amount = data.get("total_amount");
			Object del_amount = data.get("del_amount");
			Object recp_amount = data.get("recp_amount");
			Object del_ratio = data.get("del_ratio");
			Object recp_ratio = data.get("recp_ratio");
			if("2".equals(type)) {
				Object drugCat = data.get("drug_cat");
				data.put("drug_cat", drugCat==null?"其他":("1".equals(drugCat.toString())?"西药":"中药"));
			}
			if("1".equals(type)) {
				Object classify = data.get("hosp_classify");
				data.put("hosp_classify", classify==null?"":("1".equals(classify.toString())?"县级及县以上医疗机构":"基层医院"));
			}
			data.put("total_amount", total_amount==null?"":ParseNumber.toStrDecimal(ParseNumber.toDouble(total_amount.toString()), 6));
			data.put("del_amount", del_amount==null?"":ParseNumber.toStrDecimal(ParseNumber.toDouble(del_amount.toString()), 6));
			data.put("recp_amount", recp_amount==null?"":ParseNumber.toStrDecimal(ParseNumber.toDouble(recp_amount.toString()), 6));
			data.put("del_ratio", del_ratio==null?"":ParseNumber.toStrDecimal(Double.parseDouble(del_ratio.toString())*100,6)+"%");
			data.put("recp_ratio", recp_ratio==null?"":ParseNumber.toStrDecimal(Double.parseDouble(recp_ratio.toString())*100,6)+"%");
			if(date.indexOf("-") >= 0) {
				data.put("date", page.getConditions().get("startDate")+"-"+page.getConditions().get("endDate"));
			}else {
				data.put("date", date);
			}
		}
		
		return page;	
	}
	
	
	/**
	 * @category 生产企业采购情况
	 * @date 2015年12月1日10:55:55
	 * @author lil
	 * @return
	 */
	@SuppressWarnings("unchecked")
	@Override
	public Pagination getAnaByProdcomp(Pagination page, String type) {
		List<Map<String,Object>> list = (List<Map<String, Object>>) anaDruginfoDao.getAnaByProdcomp(page, type).getRows();
		for(Map<String,Object> data : list){
			Object total_amount = data.get("total_amount");
			Object western_amount = data.get("western_amount");
			Object eastern_amount = data.get("eastern_amount");
			Object del_amount = data.get("del_amount");
			Object recp_amount = data.get("recp_amount");
			Object eastern_ratio = data.get("eastern_ratio");
			Object del_ratio = data.get("del_ratio");
			Object recp_ratio = data.get("recp_ratio");
			Object ret_ratio = data.get("ret_ratio");
			data.put("total_amount", total_amount==null?"":ParseNumber.toStrDecimal(ParseNumber.toDouble(total_amount.toString()), 6));
			data.put("western_amount", western_amount==null?"":ParseNumber.toStrDecimal(ParseNumber.toDouble(western_amount.toString()), 6));
			data.put("eastern_amount", eastern_amount==null?"":ParseNumber.toStrDecimal(ParseNumber.toDouble(eastern_amount.toString()), 6));
			data.put("del_amount", del_amount==null?"":ParseNumber.toStrDecimal(ParseNumber.toDouble(del_amount.toString()), 6));
			data.put("recp_amount", recp_amount==null?"":ParseNumber.toStrDecimal(ParseNumber.toDouble(recp_amount.toString()), 6));
			data.put("eastern_ratio", eastern_ratio==null?"":ParseNumber.toStrDecimal(Double.parseDouble(eastern_ratio.toString())*100,6)+"%");
			data.put("del_ratio", del_ratio==null?"":ParseNumber.toStrDecimal(Double.parseDouble(del_ratio.toString())*100,6)+"%");
			data.put("recp_ratio", recp_ratio==null?"":ParseNumber.toStrDecimal(Double.parseDouble(recp_ratio.toString())*100,6)+"%");
			data.put("ret_ratio", ret_ratio==null?"":ParseNumber.toStrDecimal(Double.parseDouble(ret_ratio.toString())*100,6)+"%");
			
			if (StringUtils.isNotBlank(page.getConditions().get("startDate")) && !StringUtils.isNotBlank(page.getConditions().get("endDate"))){
//				data.put("date", page.getConditions().get("startDate")+"-"+ParseDate.parseDateToYm(ParseDate.addMonth(new Date(), -1)));
				data.put("date", page.getConditions().get("startDate")+"-"+ParseDate.parseDateToYm(new Date()));
			}else if (StringUtils.isNotBlank(page.getConditions().get("startDate")) && StringUtils.isNotBlank(page.getConditions().get("endDate"))){
				data.put("date", page.getConditions().get("startDate")+"-"+page.getConditions().get("endDate"));
			}
		}
		
	/*	//获取药品采购总量月汇总集合
		List<Map<String, Object>> totalList = (List<Map<String, Object>>) anaDruginfoDao.getAnaTotalByCompLastMonth(page);
		String yComp = "[";//图表y轴时间
		String total = "[";//采购金额
		//循环解析数据
		for(int i =0;i<totalList.size();i++) {
			Map<String, Object> map = totalList.get(i);
			String hospName =  map.get("del_comp_name").toString();
			yComp = yComp +"'"+hospName+ "',";
			total = total + map.get("total_amount") + ",";
		}
		
		if(!"[".equals(yComp)) {//判断是否为空
			yComp = yComp.substring(0, yComp.length()-1) + "]";
			total = total.substring(0, total.length()-1) + "]";
			
			page.getConditions().put("yComp", yComp);
			page.getConditions().put("total", total);
		}*/
		return page;
	}
	
	/**
	 * @category 获取生产企业采购情况排名数据（月）
	 * @date 2015年12月1日10:55:55
	 * @author lil
	 * @return
	 */
	public Pagination getAnaByProdcompChartWithMon(Pagination page){
		
		//获取药品采购总量月汇总集合
				List<Map<String, Object>> chartList = anaDruginfoDao.getAnaByProdcompChartWithMon(page);
				String yComp = "[";//图表y轴时间
				String total = "[";//采购金额
				//循环解析数据
				for(int i =chartList.size()-1;i>=0;i--) {
					Map<String, Object> map = chartList.get(i);
					String hospName =  map.get("prod_comp_name").toString();
					yComp = yComp +"'"+hospName+ "',";
					total = total + map.get("total_amount") + ",";
				}
				
				if(!"[".equals(yComp)) {//判断是否为空
					yComp = yComp.substring(0, yComp.length()-1) + "]";
					total = total.substring(0, total.length()-1) + "]";
					
					page.getConditions().put("yComp", yComp);
					page.getConditions().put("total", total);
				}
				return page;
	}	
	
	
	
	
	/**
	 * @category 通体采购情况跳转采购药品(月度)
	 * @date 2015-12-04
	 * @author lil
	 * @param page
	 * @return Pagination
	 */
	@SuppressWarnings("unchecked")
	@Override
	public Pagination getAnaByAllToDrugMon(Pagination page) {
		
		String date = page.getConditions().get("date");
		if(date.indexOf("-") >= 0) {
			page.getConditions().put("starttime", date.substring(0, date.indexOf("-")));
			page.getConditions().put("endtime", date.substring(date.indexOf("-")+1, date.length()));
		}else {
			page.getConditions().put("starttime", date);
			page.getConditions().put("endtime", date);
		}
		
		//获取药品采购月汇总信息
		Pagination anaTotal = anaDruginfoDao.getAnaByAllToDrugMon(page);
		formatAna((List<Map<String,Object>>)anaTotal.getRows());
		
		
		return anaTotal;
	}
	
	/**
	 * 
	 *@category 获取地区采购情况排名数据（月）
	 *@author lil
	 *@date 2015年12月3日 上午10:06:50
	 *@param 
	 *@return Pagination
	 */
	public Pagination getAnaByAreaChartWithMon(Pagination page){
		
		//获取地区销售量前十的上一月地区信息
		List<Map<String, Object>> chartList = anaDruginfoDao.getAnaChartByAreaWithMon(page);
		String yArea = "[";//图表y轴时间
		String total = "[";//采购金额
		//循环解析数据
		for(int i =chartList.size()-1;i>=0;i--) {
			Map<String, Object> map = chartList.get(i);
			yArea = yArea +"'"+map.get("area_name")+ "',";
			total = total + map.get("total_amount") + ",";
		}
		
		if(!"[".equals(yArea)) {//判断是否为空
			yArea = yArea.substring(0, yArea.length()-1) + "]";
			total = total.substring(0, total.length()-1) + "]";
			
			page.getConditions().put("yArea", yArea);
			page.getConditions().put("total", total);
		}
		
		return page;
	}

	/**
	 * 
	 *@category 获取医疗采购情况排名数据（月）
	 *@author lil
	 *@date 2015年12月3日 上午10:06:50
	 *@param 
	 *@return Pagination
	 */
	public Pagination getMonthAnaByHosps(Pagination page){
		
		//获取地区销售量前十的上一月地区信息
		List<Map<String, Object>> chartList = anaDruginfoDao.getMonthAnaByHosps(page);
		String yArea = "[";//图表y轴时间
		String total = "[";//采购金额
		//循环解析数据
		for(int i =chartList.size()-1;i>=0;i--) {
			Map<String, Object> map = chartList.get(i);
			yArea = yArea +"'"+map.get("hosp_name")+ "',";
			total = total + map.get("total_amount") + ",";
		}
		
		if(!"[".equals(yArea)) {//判断是否为空
			yArea = yArea.substring(0, yArea.length()-1) + "]";
			total = total.substring(0, total.length()-1) + "]";
			
			page.getConditions().put("yArea", yArea);
			page.getConditions().put("total", total);
		}
		
		return page;
	}
	

		@Override
	public Pagination getAnaByDrugsWithMonByMchart(Pagination page) {
		
		//获取药品采购总量月汇总集合
		List<Map<String, Object>> list = anaDruginfoDao.getAnaChartByDrugsMon(page);
		String yDrug = "[";//图表y轴时间
		String total = "[";//采购金额
		//循环解析数据
		for(int i =list.size()-1;i>=0;i--) {
			Map<String, Object> map = list.get(i);
			yDrug = yDrug +"'"+map.get("drug_name")+ "',";
			String totalAmount = map.get("total_amount")==null?"":ParseNumber.toStrDecimal(ParseNumber.toDouble(map.get("total_amount").toString())/10000, 6);
			total = total +totalAmount + ",";
			
		}
		if(!"[".equals(yDrug)) {//判断是否为空
			yDrug = yDrug.substring(0, yDrug.length()-1) + "]";
			total = total.substring(0, total.length()-1) + "]";
			page.getConditions().put("yDrug", yDrug);
			page.getConditions().put("total", total);
		}
		return page;
	}

	
	@SuppressWarnings("unchecked")
	@Override
	public Pagination getAnaHospdruginfoTotalByDrug(Pagination page) {
		String areaId =  AreaUtil.getAreaStartCode(page.getConditions().get("area1"), page.getConditions().get("area2"), page.getConditions().get("area3"));
		if(StringUtils.isNotBlank(areaId)){
			page.getConditions().put("areaId", areaId);
		}
		
		String[] dateStr =  page.getConditions().get("date").split("-");
		if(dateStr.length==2){
			page.getConditions().put("starttime", dateStr[0]);
			page.getConditions().put("endtime", dateStr[1]);
			page = anaDruginfoDao.getAnaHospdruginfoTotalByDrugPool(page);
		}else{
			page = anaDruginfoDao.getAnaHospdruginfoTotalByDrug(page);
		}
		formatAna((List<Map<String,Object>>)page.getRows());
		return page;
	}

	
	/**
	 * @category 地区采购情况跳转无分页
	 * @date 2015年12月1日10:55:55
	 * @author lil
	 * @return
	 */
	@SuppressWarnings("unchecked")
	@Override
	public Pagination getAnaByAreaTzNoPage(Pagination page) {
		
		String date = page.getConditions().get("date");
		if(date.indexOf("-") >= 0) {
			page.getConditions().put("startDate", date.substring(0, date.indexOf("-")));
			page.getConditions().put("endDate", date.substring(date.indexOf("-")+1, date.length()));
		}else {
			page.getConditions().put("startDate", date);
			page.getConditions().put("endDate", date);
		}
		
		List<Map<String,Object>> list = (List<Map<String, Object>>) anaDruginfoDao.getAnaByAreaTzNoPage(page).getRows();
		for(Map<String,Object> data : list){
			Object total_amount = data.get("total_amount");
			Object del_amount = data.get("del_amount");
			Object recp_amount = data.get("recp_amount");
			Object del_ratio = data.get("del_ratio");
			Object recp_ratio = data.get("recp_ratio");
			data.put("total_amount", total_amount==null?"":ParseNumber.toStrDecimal(ParseNumber.toDouble(total_amount.toString()), 6));
			data.put("del_amount", del_amount==null?"":ParseNumber.toStrDecimal(ParseNumber.toDouble(del_amount.toString()), 6));
			data.put("recp_amount", recp_amount==null?"":ParseNumber.toStrDecimal(ParseNumber.toDouble(recp_amount.toString()), 6));
			data.put("del_ratio", del_ratio==null?"":ParseNumber.toStrDecimal(Double.parseDouble(del_ratio.toString())*100,6)+"%");
			data.put("recp_ratio", recp_ratio==null?"":ParseNumber.toStrDecimal(Double.parseDouble(recp_ratio.toString())*100,6)+"%");
			if(date.indexOf("-") >= 0) {
				data.put("date", page.getConditions().get("startDate")+"-"+page.getConditions().get("endDate"));
			}else {
				data.put("date", date);
			}
		}
		
		return page;	
	}
	
	
	/**
	 * @category 总体采购情况情况跳转
	 * @date 2015年12月1日10:55:55
	 * @author lil
	 * @return
	 */
	@SuppressWarnings("unchecked")
	@Override
	public Pagination getAnaByAllTz(Pagination page) {
		
		String date = page.getConditions().get("date");
		String type = page.getConditions().get("type");
		if(date.indexOf("-") >= 0) {
			page.getConditions().put("startDate", date.substring(0, date.indexOf("-")));
			page.getConditions().put("endDate", date.substring(date.indexOf("-")+1, date.length()));
		}else {
			page.getConditions().put("startDate", date);
			page.getConditions().put("endDate", date);
		}
		
		List<Map<String,Object>> list = (List<Map<String, Object>>) anaDruginfoDao.getAnaByAllTz(page).getRows();
		for(Map<String,Object> data : list){
			Object total_amount = data.get("total_amount");
			Object del_amount = data.get("del_amount");
			Object recp_amount = data.get("recp_amount");
			Object del_ratio = data.get("del_ratio");
			Object recp_ratio = data.get("recp_ratio");
			if("2".equals(type)) {
				Object drugCat = data.get("drug_cat");
				data.put("drug_cat", drugCat.equals("null")?"其他":("1".equals(drugCat.toString())?"西药":"中药"));
			}
			if("1".equals(type)) {
				Object classify = data.get("hosp_classify");
				data.put("hosp_classify", classify.equals("null")?"其他":("1".equals(classify.toString())?"县级及县以上医疗机构":"基层医院"));
			}
			data.put("total_amount", total_amount==null?"":ParseNumber.toStrDecimal(ParseNumber.toDouble(total_amount.toString()), 6));
			data.put("del_amount", del_amount==null?"":ParseNumber.toStrDecimal(ParseNumber.toDouble(del_amount.toString()), 6));
			data.put("recp_amount", recp_amount==null?"":ParseNumber.toStrDecimal(ParseNumber.toDouble(recp_amount.toString()), 6));
			data.put("del_ratio", del_ratio==null?"":ParseNumber.toStrDecimal(Double.parseDouble(del_ratio.toString())*100,6)+"%");
			data.put("recp_ratio", recp_ratio==null?"":ParseNumber.toStrDecimal(Double.parseDouble(recp_ratio.toString())*100,6)+"%");
			if(date.indexOf("-") >= 0) {
				data.put("date", page.getConditions().get("startDate")+"-"+page.getConditions().get("endDate"));
			}else {
				data.put("date", date);
			}
		}
		
		return page;	
	}
	

	/**
	 * @category 总体采购情况情况跳转无分页
	 * @date 2015年12月1日10:55:55
	 * @author lil
	 * @return
	 */
	@SuppressWarnings("unchecked")
	@Override
	public Pagination getAnaByAllTzNoPage(Pagination page) {
		
		String date = page.getConditions().get("date");
		if(date.indexOf("-") >= 0) {
			page.getConditions().put("startDate", date.substring(0, date.indexOf("-")));
			page.getConditions().put("endDate", date.substring(date.indexOf("-")+1, date.length()));
		}else {
			page.getConditions().put("startDate", date);
			page.getConditions().put("endDate", date);
		}
		
		List<Map<String,Object>> list = (List<Map<String, Object>>) anaDruginfoDao.getAnaByAllTzNoPage(page).getRows();
		for(Map<String,Object> data : list){
			Object drugCat = data.get("drug_cat");
			Object total_amount = data.get("total_amount");
			Object del_amount = data.get("del_amount");
			Object recp_amount = data.get("recp_amount");
			Object del_ratio = data.get("del_ratio");
			Object recp_ratio = data.get("recp_ratio");
			data.put("drug_cat", drugCat==null?"":(drugCat.toString().equals("1")?"西药":"中药"));
			data.put("total_amount", total_amount==null?"":ParseNumber.toStrDecimal(ParseNumber.toDouble(total_amount.toString()), 6));
			data.put("del_amount", del_amount==null?"":ParseNumber.toStrDecimal(ParseNumber.toDouble(del_amount.toString()), 6));
			data.put("recp_amount", recp_amount==null?"":ParseNumber.toStrDecimal(ParseNumber.toDouble(recp_amount.toString()), 6));
			data.put("del_ratio", del_ratio==null?"":ParseNumber.toStrDecimal(Double.parseDouble(del_ratio.toString())*100,6)+"%");
			data.put("recp_ratio", recp_ratio==null?"":ParseNumber.toStrDecimal(Double.parseDouble(recp_ratio.toString())*100,6)+"%");
			if(date.indexOf("-") >= 0) {
				data.put("date", page.getConditions().get("startDate")+"-"+page.getConditions().get("endDate"));
			}else {
				data.put("date", date);
			}
		}
		
		return page;	
	}
	@SuppressWarnings("unchecked")
	@Override
	public Pagination getAnaProddruginfoTotal(Pagination page) {
		String[] dateStr =  page.getConditions().get("date").split("-");
		if(dateStr.length==2){
			page.getConditions().put("starttime", dateStr[0]);
			page.getConditions().put("endtime", dateStr[1]);
			page = anaDruginfoDao.getAnaProddruginfoTotalPool(page);
		}else{
			page = anaDruginfoDao.getAnaProddruginfoTotal(page);
		}
		formatAna((List<Map<String,Object>>)page.getRows());
		return page;
	
	}
	
	
	/**
	 * @category 生产企业采购情况情况跳转
	 * @date 2015年12月1日10:55:55
	 * @author lil
	 * @return
	 */
	@SuppressWarnings("unchecked")
	@Override
	public Pagination getAnaByProdcompTz(Pagination page) {
		
		String date = page.getConditions().get("date");
		String type = page.getConditions().get("type");
		if(date.indexOf("-") >= 0) {
			page.getConditions().put("startDate", date.substring(0, date.indexOf("-")));
			page.getConditions().put("endDate", date.substring(date.indexOf("-")+1, date.length()));
		}else {
			page.getConditions().put("startDate", date);
			page.getConditions().put("endDate", date);
		}
		
		List<Map<String,Object>> list = (List<Map<String, Object>>) anaDruginfoDao.getAnaByProdcompTz(page).getRows();
		for(Map<String,Object> data : list){
			Object total_amount = data.get("total_amount");
			Object del_amount = data.get("del_amount");
			Object recp_amount = data.get("recp_amount");
			Object del_ratio = data.get("del_ratio");
			Object recp_ratio = data.get("recp_ratio");
			if("2".equals(type)) {
				Object drugCat = data.get("drug_cat");
				data.put("drug_cat", drugCat.equals("null")?"其他":("1".equals(drugCat.toString())?"西药":"中药"));
			}
			if("1".equals(type)) {
				Object classify = data.get("hosp_classify");
				data.put("hosp_classify", classify.equals("null")?"其他":("1".equals(classify.toString())?"县级及县以上医疗机构":"基层医院"));
			}
			data.put("total_amount", total_amount==null?"":ParseNumber.toStrDecimal(ParseNumber.toDouble(total_amount.toString()), 6));
			data.put("del_amount", del_amount==null?"":ParseNumber.toStrDecimal(ParseNumber.toDouble(del_amount.toString()), 6));
			data.put("recp_amount", recp_amount==null?"":ParseNumber.toStrDecimal(ParseNumber.toDouble(recp_amount.toString()), 6));
			data.put("del_ratio", del_ratio==null?"":ParseNumber.toStrDecimal(Double.parseDouble(del_ratio.toString())*100,6)+"%");
			data.put("recp_ratio", recp_ratio==null?"":ParseNumber.toStrDecimal(Double.parseDouble(recp_ratio.toString())*100,6)+"%");
			if(date.indexOf("-") >= 0) {
				data.put("date", page.getConditions().get("startDate")+"-"+page.getConditions().get("endDate"));
			}else {
				data.put("date", date);
			}
		}
		
		return page;	
	}
	
	
	
	

	/**
	 * 
	 *@category 获取企业采购情况排名数据（月）
	 *@author lil
	 *@date 2015年12月3日 上午10:06:50
	 *@param 
	 *@return Pagination
	 */
	@SuppressWarnings("unchecked")
	@Override
	public Pagination getChartMonthAnaByComp(Pagination page){
		//获取药品采购总量月汇总集合
		List<Map<String, Object>> totalList = (List<Map<String, Object>>) anaDruginfoDao.getAnaTotalByCompLastMonth(page);
		String yComp = "[";//图表y轴时间
		String total = "[";//采购金额
		//循环解析数据
		for(int i =totalList.size()-1;i>=0;i--) {
			Map<String, Object> map = totalList.get(i);
			String hospName =  map.get("del_comp_name").toString();
			yComp = yComp +"'"+hospName+ "',";
			total = total + map.get("total_amount") + ",";
		}
				
		if(!"[".equals(yComp)) {//判断是否为空
			yComp = yComp.substring(0, yComp.length()-1) + "]";
			total = total.substring(0, total.length()-1) + "]";
					
			page.getConditions().put("yComp", yComp);
			page.getConditions().put("total", total);
		}
		return page;
	}

	/**
	 * @category 配送企业药品统计信息
	 * @date 2015年12月1日10:55:55
	 * @author wangbing
	 * @return
	 */
	@SuppressWarnings("unchecked")
	@Override
	public Pagination getAnaDelByDrugExport(Pagination page, String type){
		page =  anaDruginfoDao.getAnaDelByDrugExport(page, type);
		List<Map<String, Object>> list = (List<Map<String, Object>>) page.getRows();
		if (null != list && list.size() > 0){
			for (int i = 0; i < list.size(); i++){
				Map<String, Object> map = list.get(i);
				map.put("total_amount", map.get("total_amount")==null?"":ParseNumber.toStrDecimal(ParseNumber.toDouble(map.get("total_amount").toString()), 6));
				map.put("del_amount", map.get("del_amount")==null?"":ParseNumber.toStrDecimal(ParseNumber.toDouble(map.get("del_amount").toString()), 6));
				map.put("recp_amount", map.get("recp_amount")==null?"":ParseNumber.toStrDecimal(ParseNumber.toDouble(map.get("recp_amount").toString()), 6));
				map.put("ret_amount", map.get("ret_amount")==null?"":ParseNumber.toStrDecimal(ParseNumber.toDouble(map.get("ret_amount").toString()), 6));
				map.put("del_ratio", map.get("del_ratio")==null?"":ParseNumber.toStrDecimal(ParseNumber.toDouble(map.get("del_ratio").toString()) * 100, 6) + "%");
				map.put("recp_ratio", map.get("recp_ratio")==null?"":ParseNumber.toStrDecimal(ParseNumber.toDouble(map.get("recp_ratio").toString()) * 100, 6) + "%");
				map.put("ret_ratio", map.get("ret_ratio")==null?"":ParseNumber.toStrDecimal(ParseNumber.toDouble(map.get("ret_ratio").toString()) * 100, 6) + "%");
			}
		}
		return page;
	}
	
	@SuppressWarnings("unchecked")
	@Override
	public Pagination getAnaCompinfoByAreaWithMonExport(Pagination page){
		page =  anaDruginfoDao.getAnaCompinfoByAreaWithMonExport(page);
		List<Map<String, Object>> list = (List<Map<String, Object>>) page.getRows();
		if (null != list && list.size() > 0){
			for (int i = 0; i < list.size(); i++){
				Map<String, Object> map = list.get(i);
				map.put("total_amount", map.get("total_amount")==null?"":ParseNumber.toStrDecimal(ParseNumber.toDouble(map.get("total_amount").toString()), 6));
				map.put("western_amount", map.get("western_amount")==null?"":ParseNumber.toStrDecimal(ParseNumber.toDouble(map.get("western_amount").toString()), 6));
				map.put("eastern_amount", map.get("eastern_amount")==null?"":ParseNumber.toStrDecimal(ParseNumber.toDouble(map.get("eastern_amount").toString()), 6));
				map.put("del_amount", map.get("del_amount")==null?"":ParseNumber.toStrDecimal(ParseNumber.toDouble(map.get("del_amount").toString()), 6));
				map.put("recp_amount", map.get("recp_amount")==null?"":ParseNumber.toStrDecimal(ParseNumber.toDouble(map.get("recp_amount").toString()), 6));
				map.put("eastern_ratio", map.get("eastern_ratio")==null?"":ParseNumber.toStrDecimal(ParseNumber.toDouble(map.get("eastern_ratio").toString()) * 100, 6) + "%");
				map.put("del_ratio", map.get("del_ratio")==null?"":ParseNumber.toStrDecimal(ParseNumber.toDouble(map.get("del_ratio").toString()) * 100, 6) + "%");
				map.put("recp_ratio", map.get("recp_ratio")==null?"":ParseNumber.toStrDecimal(ParseNumber.toDouble(map.get("recp_ratio").toString()) * 100, 6) + "%");
				map.put("ret_ratio", map.get("ret_ratio")==null?"":ParseNumber.toStrDecimal(ParseNumber.toDouble(map.get("ret_ratio").toString()) * 100, 6) + "%");
			}
		}
		return page;
	}
	
	@SuppressWarnings("unchecked")
	@Override
	public Pagination getAnaDelByHosp(Pagination page){
		page =  anaDruginfoDao.getAnaDelByHosp(page);
		List<Map<String, Object>> list = (List<Map<String, Object>>) page.getRows();
		if (null != list && list.size() > 0){
			for (int i = 0; i < list.size(); i++){
				Map<String, Object> map = list.get(i);
				Object hosp_classify = map.get("hosp_classify");
				map.put("hosp_classify", hosp_classify==null?"":"1".equals(hosp_classify.toString())?"县及县以上医院":"基层医院");
				map.put("total_amount", map.get("total_amount")==null?"":ParseNumber.toStrDecimal(ParseNumber.toDouble(map.get("total_amount").toString()), 6));
				map.put("western_amount", map.get("western_amount")==null?"":ParseNumber.toStrDecimal(ParseNumber.toDouble(map.get("western_amount").toString()), 6));
				map.put("eastern_amount", map.get("eastern_amount")==null?"":ParseNumber.toStrDecimal(ParseNumber.toDouble(map.get("eastern_amount").toString()), 6));
				map.put("del_amount", map.get("del_amount")==null?"":ParseNumber.toStrDecimal(ParseNumber.toDouble(map.get("del_amount").toString()), 6));
				map.put("recp_amount", map.get("recp_amount")==null?"":ParseNumber.toStrDecimal(ParseNumber.toDouble(map.get("recp_amount").toString()), 6));
				map.put("eastern_ratio", map.get("eastern_ratio")==null?"":ParseNumber.toStrDecimal(ParseNumber.toDouble(map.get("eastern_ratio").toString()) * 100, 6) + "%");
				map.put("del_ratio", map.get("del_ratio")==null?"":ParseNumber.toStrDecimal(ParseNumber.toDouble(map.get("del_ratio").toString()) * 100, 6) + "%");
				map.put("recp_ratio", map.get("recp_ratio")==null?"":ParseNumber.toStrDecimal(ParseNumber.toDouble(map.get("recp_ratio").toString()) * 100, 6) + "%");
				map.put("ret_ratio", map.get("ret_ratio")==null?"":ParseNumber.toStrDecimal(ParseNumber.toDouble(map.get("ret_ratio").toString()) * 100, 6) + "%");
			}
		}
		return page;
	}
	
	@SuppressWarnings("unchecked")
	@Override
	public Pagination getAnaDelByHospExport(Pagination page){
		page =  anaDruginfoDao.getAnaDelByHospExport(page);
		List<Map<String, Object>> list = (List<Map<String, Object>>) page.getRows();
		if (null != list && list.size() > 0){
			for (int i = 0; i < list.size(); i++){
				Map<String, Object> map = list.get(i);
				Object hosp_classify = map.get("hosp_classify");
				map.put("hosp_classify", hosp_classify==null?"":"1".equals(hosp_classify.toString())?"县及县以上医院":"基层医院");
				map.put("total_amount", map.get("total_amount")==null?"":ParseNumber.toStrDecimal(ParseNumber.toDouble(map.get("total_amount").toString()), 6));
				map.put("western_amount", map.get("western_amount")==null?"":ParseNumber.toStrDecimal(ParseNumber.toDouble(map.get("western_amount").toString()), 6));
				map.put("eastern_amount", map.get("eastern_amount")==null?"":ParseNumber.toStrDecimal(ParseNumber.toDouble(map.get("eastern_amount").toString()), 6));
				map.put("del_amount", map.get("del_amount")==null?"":ParseNumber.toStrDecimal(ParseNumber.toDouble(map.get("del_amount").toString()), 6));
				map.put("recp_amount", map.get("recp_amount")==null?"":ParseNumber.toStrDecimal(ParseNumber.toDouble(map.get("recp_amount").toString()), 6));
				map.put("eastern_ratio", map.get("eastern_ratio")==null?"":ParseNumber.toStrDecimal(ParseNumber.toDouble(map.get("eastern_ratio").toString()) * 100, 6) + "%");
				map.put("del_ratio", map.get("del_ratio")==null?"":ParseNumber.toStrDecimal(ParseNumber.toDouble(map.get("del_ratio").toString()) * 100, 6) + "%");
				map.put("recp_ratio", map.get("recp_ratio")==null?"":ParseNumber.toStrDecimal(ParseNumber.toDouble(map.get("recp_ratio").toString()) * 100, 6) + "%");
				map.put("ret_ratio", map.get("ret_ratio")==null?"":ParseNumber.toStrDecimal(ParseNumber.toDouble(map.get("ret_ratio").toString()) * 100, 6) + "%");
			}
		}
		return page;
	}
	
	@SuppressWarnings("unchecked")
	@Override
	public Pagination getAnaDelByProdComp(Pagination page){
		page =  anaDruginfoDao.getAnaDelByProdComp(page);
		List<Map<String, Object>> list = (List<Map<String, Object>>) page.getRows();
		if (null != list && list.size() > 0){
			for (int i = 0; i < list.size(); i++){
				Map<String, Object> map = list.get(i);
				map.put("total_amount", map.get("total_amount")==null?"":ParseNumber.toStrDecimal(ParseNumber.toDouble(map.get("total_amount").toString()), 6));
				map.put("western_amount", map.get("western_amount")==null?"":ParseNumber.toStrDecimal(ParseNumber.toDouble(map.get("western_amount").toString()), 6));
				map.put("eastern_amount", map.get("eastern_amount")==null?"":ParseNumber.toStrDecimal(ParseNumber.toDouble(map.get("eastern_amount").toString()), 6));
				map.put("del_amount", map.get("del_amount")==null?"":ParseNumber.toStrDecimal(ParseNumber.toDouble(map.get("del_amount").toString()), 6));
				map.put("recp_amount", map.get("recp_amount")==null?"":ParseNumber.toStrDecimal(ParseNumber.toDouble(map.get("recp_amount").toString()), 6));
				map.put("eastern_ratio", map.get("eastern_ratio")==null?"":ParseNumber.toStrDecimal(ParseNumber.toDouble(map.get("eastern_ratio").toString()) * 100, 6) + "%");
				map.put("del_ratio", map.get("del_ratio")==null?"":ParseNumber.toStrDecimal(ParseNumber.toDouble(map.get("del_ratio").toString()) * 100, 6) + "%");
				map.put("recp_ratio", map.get("recp_ratio")==null?"":ParseNumber.toStrDecimal(ParseNumber.toDouble(map.get("recp_ratio").toString()) * 100, 6) + "%");
				map.put("ret_ratio", map.get("ret_ratio")==null?"":ParseNumber.toStrDecimal(ParseNumber.toDouble(map.get("ret_ratio").toString()) * 100, 6) + "%");
			}
		}
		return page;
	}
	
	@SuppressWarnings("unchecked")
	@Override
	public Pagination getAnaDelByProdCompExport(Pagination page){
		page =  anaDruginfoDao.getAnaDelByProdCompExport(page);
		List<Map<String, Object>> list = (List<Map<String, Object>>) page.getRows();
		if (null != list && list.size() > 0){
			for (int i = 0; i < list.size(); i++){
				Map<String, Object> map = list.get(i);
				map.put("total_amount", map.get("total_amount")==null?"":ParseNumber.toStrDecimal(ParseNumber.toDouble(map.get("total_amount").toString()), 6));
				map.put("western_amount", map.get("western_amount")==null?"":ParseNumber.toStrDecimal(ParseNumber.toDouble(map.get("western_amount").toString()), 6));
				map.put("eastern_amount", map.get("eastern_amount")==null?"":ParseNumber.toStrDecimal(ParseNumber.toDouble(map.get("eastern_amount").toString()), 6));
				map.put("del_amount", map.get("del_amount")==null?"":ParseNumber.toStrDecimal(ParseNumber.toDouble(map.get("del_amount").toString()), 6));
				map.put("recp_amount", map.get("recp_amount")==null?"":ParseNumber.toStrDecimal(ParseNumber.toDouble(map.get("recp_amount").toString()), 6));
				map.put("eastern_ratio", map.get("eastern_ratio")==null?"":ParseNumber.toStrDecimal(ParseNumber.toDouble(map.get("eastern_ratio").toString()) * 100, 6) + "%");
				map.put("del_ratio", map.get("del_ratio")==null?"":ParseNumber.toStrDecimal(ParseNumber.toDouble(map.get("del_ratio").toString()) * 100, 6) + "%");
				map.put("recp_ratio", map.get("recp_ratio")==null?"":ParseNumber.toStrDecimal(ParseNumber.toDouble(map.get("recp_ratio").toString()) * 100, 6) + "%");
				map.put("ret_ratio", map.get("ret_ratio")==null?"":ParseNumber.toStrDecimal(ParseNumber.toDouble(map.get("ret_ratio").toString()) * 100, 6) + "%");
			}
		}
		return page;
	}
	
	/**
	 * @category 获取   配送企业-药品-医疗机构   列表数据
	 * @date 2015年12月1日10:55:55
	 * @author lil
	 * @return
	 */
	@SuppressWarnings("unchecked")
	@Override
	public Pagination getAnaDelByDrugHospWithMon(Pagination page, String type){
		page =  anaDruginfoDao.getAnaDelByDrugHospWithMon(page, type);
		List<Map<String, Object>> list = (List<Map<String, Object>>) page.getRows();
		if (null != list && list.size() > 0){
			for (int i = 0; i < list.size(); i++){
				Map<String, Object> map = list.get(i);
				Object hosp_classify = map.get("hosp_classify");
				Object drugCat = map.get("drug_cat");
				map.put("drug_cat", drugCat==null?"":(drugCat.toString().equals("1")?"西药":"中药"));
				map.put("hosp_classify", hosp_classify==null?"":"1".equals(hosp_classify.toString())?"县及县以上医院":"基层医院");
				map.put("total_amount", map.get("total_amount")==null?"":ParseNumber.toStrDecimal(ParseNumber.toDouble(map.get("total_amount").toString()), 6));
				map.put("del_amount", map.get("del_amount")==null?"":ParseNumber.toStrDecimal(ParseNumber.toDouble(map.get("del_amount").toString()), 6));
				map.put("recp_amount", map.get("recp_amount")==null?"":ParseNumber.toStrDecimal(ParseNumber.toDouble(map.get("recp_amount").toString()), 6));
				map.put("ret_amount", map.get("ret_amount")==null?"":ParseNumber.toStrDecimal(ParseNumber.toDouble(map.get("ret_amount").toString()), 6));
				map.put("del_ratio", map.get("del_ratio")==null?"":ParseNumber.toStrDecimal(ParseNumber.toDouble(map.get("del_ratio").toString()) * 100, 6) + "%");
				map.put("recp_ratio", map.get("recp_ratio")==null?"":ParseNumber.toStrDecimal(ParseNumber.toDouble(map.get("recp_ratio").toString()) * 100, 6) + "%");
				map.put("ret_ratio", map.get("ret_ratio")==null?"":ParseNumber.toStrDecimal(ParseNumber.toDouble(map.get("ret_ratio").toString()) * 100, 6) + "%");
			}
		}
		return page;
	}
	
	
	/**
	 * @category 生产企业采购情况情况跳转三级
	 * @date 2015年12月1日10:55:55
	 * @author lil
	 * @return
	 */
	@SuppressWarnings("unchecked")
	@Override
	public Pagination getAnaByProdcompTzThree(Pagination page) {
		
		String date = page.getConditions().get("date");
		String type = page.getConditions().get("type");
		if(date.indexOf("-") >= 0) {
			page.getConditions().put("startDate", date.substring(0, date.indexOf("-")));
			page.getConditions().put("endDate", date.substring(date.indexOf("-")+1, date.length()));
		}else {
			page.getConditions().put("startDate", date);
			page.getConditions().put("endDate", date);
		}
		
		List<Map<String,Object>> list = (List<Map<String, Object>>) anaDruginfoDao.getAnaByProdcompTzThree(page).getRows();
		for(Map<String,Object> data : list){
			Object total_amount = data.get("total_amount");
			Object del_amount = data.get("del_amount");
			Object recp_amount = data.get("recp_amount");
			Object del_ratio = data.get("del_ratio");
			Object recp_ratio = data.get("recp_ratio");
			if("2".equals(type)) {
				Object classify = data.get("hosp_classify");
				data.put("hosp_classify", classify.equals("null")?"其他":(classify.toString().equals("1")?"县级及县以上医疗机构":"基层医院"));
			}else {
				Object drugCat = data.get("drug_cat");
				data.put("drug_cat", drugCat.equals("null")?"其他":(drugCat.toString().equals("1")?"西药":"中药"));
			}
			
			data.put("total_amount", total_amount==null?"":ParseNumber.toStrDecimal(ParseNumber.toDouble(total_amount.toString()), 6));
			data.put("del_amount", del_amount==null?"":ParseNumber.toStrDecimal(ParseNumber.toDouble(del_amount.toString()), 6));
			data.put("recp_amount", recp_amount==null?"":ParseNumber.toStrDecimal(ParseNumber.toDouble(recp_amount.toString()), 6));
			data.put("del_ratio", del_ratio==null?"":ParseNumber.toStrDecimal(Double.parseDouble(del_ratio.toString())*100,6)+"%");
			data.put("recp_ratio", recp_ratio==null?"":ParseNumber.toStrDecimal(Double.parseDouble(recp_ratio.toString())*100,6)+"%");
			if(date.indexOf("-") >= 0) {
				data.put("date", page.getConditions().get("startDate")+"-"+page.getConditions().get("endDate"));
			}else {
				data.put("date", date);
			}
		}
		
		return page;	
	}
	
	/**
	 * @category 获取   配送企业-医疗机构-药品   列表数据
	 * @date 2015年12月1日10:55:55
	 * @author wangbing
	 * @return
	 */
	@SuppressWarnings("unchecked")
	@Override
	public Pagination getAnaDelByHospDrugWithMon(Pagination page, String type){
		page =  anaDruginfoDao.getAnaDelByHospDrugWithMon(page, type);
		List<Map<String, Object>> list = (List<Map<String, Object>>) page.getRows();
		if (null != list && list.size() > 0){
			for (int i = 0; i < list.size(); i++){
				Map<String, Object> map = list.get(i);
				Object hosp_classify = map.get("hosp_classify");
				Object drug_cat = map.get("drug_cat");
				map.put("drug_cat",drug_cat==null?"":"1".equals(drug_cat.toString())?"西药":"中药");
				map.put("hosp_classify", hosp_classify==null?"":"1".equals(hosp_classify.toString())?"县及县以上医院":"基层医院");
				map.put("total_amount", map.get("total_amount")==null?"":ParseNumber.toStrDecimal(ParseNumber.toDouble(map.get("total_amount").toString()), 6));
				map.put("del_amount", map.get("del_amount")==null?"":ParseNumber.toStrDecimal(ParseNumber.toDouble(map.get("del_amount").toString()), 6));
				map.put("recp_amount", map.get("recp_amount")==null?"":ParseNumber.toStrDecimal(ParseNumber.toDouble(map.get("recp_amount").toString()), 6));
				map.put("ret_amount", map.get("ret_amount")==null?"":ParseNumber.toStrDecimal(ParseNumber.toDouble(map.get("ret_amount").toString()), 6));
				map.put("del_ratio", map.get("del_ratio")==null?"":ParseNumber.toStrDecimal(ParseNumber.toDouble(map.get("del_ratio").toString()) * 100, 6) + "%");
				map.put("recp_ratio", map.get("recp_ratio")==null?"":ParseNumber.toStrDecimal(ParseNumber.toDouble(map.get("recp_ratio").toString()) * 100, 6) + "%");
				map.put("ret_ratio", map.get("ret_ratio")==null?"":ParseNumber.toStrDecimal(ParseNumber.toDouble(map.get("ret_ratio").toString()) * 100, 6) + "%");
			}
		}
		return page;
	}
	
	/**
	 * @category 获取   配送企业-生产企业-药品   列表数据
	 * @date 2015年12月1日10:55:55
	 * @author wangbing
	 * @return
	 */
	@SuppressWarnings("unchecked")
	@Override
	public Pagination getAnaDelByProdCompDrugWithMon(Pagination page, String type){
 		page =  anaDruginfoDao.getAnaDelByProdCompDrugWithMon(page, type);
		List<Map<String, Object>> list = (List<Map<String, Object>>) page.getRows();
		if (null != list && list.size() > 0){
			for (int i = 0; i < list.size(); i++){
				Map<String, Object> map = list.get(i);
				Object drug_cat = map.get("drug_cat");
				map.put("drug_cat",drug_cat==null?"":"1".equals(drug_cat.toString())?"西药":"中药");
				map.put("total_amount", map.get("total_amount")==null?"":ParseNumber.toStrDecimal(ParseNumber.toDouble(map.get("total_amount").toString()), 6));
				map.put("del_amount", map.get("del_amount")==null?"":ParseNumber.toStrDecimal(ParseNumber.toDouble(map.get("del_amount").toString()), 6));
				map.put("recp_amount", map.get("recp_amount")==null?"":ParseNumber.toStrDecimal(ParseNumber.toDouble(map.get("recp_amount").toString()), 6));
				map.put("ret_amount", map.get("ret_amount")==null?"":ParseNumber.toStrDecimal(ParseNumber.toDouble(map.get("ret_amount").toString()), 6));
				map.put("del_ratio", map.get("del_ratio")==null?"":ParseNumber.toStrDecimal(ParseNumber.toDouble(map.get("del_ratio").toString()) * 100, 6) + "%");
				map.put("recp_ratio", map.get("recp_ratio")==null?"":ParseNumber.toStrDecimal(ParseNumber.toDouble(map.get("recp_ratio").toString()) * 100, 6) + "%");
				map.put("ret_ratio", map.get("ret_ratio")==null?"":ParseNumber.toStrDecimal(ParseNumber.toDouble(map.get("ret_ratio").toString()) * 100, 6) + "%");
			}
		}
		return page;
	}
}
